how can i change the default Message Response?

29 views
Skip to first unread message

张鑫

unread,
Aug 16, 2012, 5:38:05 AM8/16/12
to mylau...@googlegroups.com
i am a new to ios develop,i want to open another view when touch selected item, what can i do? 

CBredlow

unread,
Aug 16, 2012, 5:43:03 PM8/16/12
to mylau...@googlegroups.com
Inside the class MyLauncherViewController, the method launcherviewItemSelected is where you would add your view logic.  Unfortunately I don't have my version on me, because it has different code that launches a unique view depending on the item selected.

张鑫

unread,
Aug 16, 2012, 10:13:45 PM8/16/12
to mylau...@googlegroups.com
if i want to open a url with a webview when select item 1,what should i do? 

Jarada

unread,
Sep 12, 2012, 11:46:54 AM9/12/12
to mylau...@googlegroups.com
My suggestion:
  1. Create a UIViewController with a UIView that contains a UIWebView; standard style, with a property of NSURL. Add this as appropriate to your appControllers dictionary with key "webViewer" (for example).
  2. In your RootViewController, add a myLauncherItem, and instead of using the "webViewer" key, enter the URL you want to load, into target argument of the init method.
  3. Override launcherViewItemSelected: in your RootViewController and copy all code from MyLauncherViewController's version of the method.
  4. Replace code in launcherViewItemSelected: in RootViewController as follows below:
Replace:

Class viewCtrClass = [[self appControllers] objectForKey:[item controllerStr]];

UIViewController *controller = [[viewCtrClass alloc] init];

With:

Class viewCtrClass = nil;

UIViewController *controller = nil;

    if ([[[item controllerStr] substringToIndex:4] isEqualToString:@"http"]) {

        viewCtrClass = [[self appControllers] objectForKey:@"webViewer"];

        controller = [[viewCtrClass alloc] init];

        [(WebViewController *)controller setURL:[item controllerStr]];

    } else {

        viewCtrClass = [[self appControllers] objectForKey:[item controllerStr]];

        controller = [[viewCtrClass alloc] init];

    }

This way you can use the target / controllerStr property to pull out the correct View Controller, and use it to store the URL in. The target / controllerStr is only used to pull out the correct UIViewController from the dictionary, so this should work as intended. Then when the WebViewController is presented, just get it to auto load the URL you passed through.

I might add a dictionary to MyLauncherItem to allow the passing of data to the presented launcher item.

Reply all
Reply to author
Forward
0 new messages