我最近刚刚实现了inAppSettings工具包。我的目标是加载我的默认视图,然后在右侧添加一个名为"settings“的导航栏按钮项。一旦用户按下设置按钮,它将把他们带到我的设置捆绑包,在那里他们可以选择他们想要的网站,然后按back,这将再次加载我的默认视图,webview再次加载新的url。
我已经实现了我刚才描述的所有东西,但是一旦在设置中进行了选择,用户按下了back (也就是关闭设置视图返回到默认视图),应用程序就会崩溃,我不知道为什么。我的代码如下,如果有人知道为什么会发生这种情况,我将不胜感激。需要注意的是,一旦我在应用程序崩溃后再次运行它,网站就会根据他们在崩溃前选择的设置正确加载。
附注:用户可以点击选择的选项有: Google,stackoverflow。
错误消息:由于未捕获异常'NSInvalidArgumentException',正在终止应用程序,原因:‘-即将到来的settingsViewControllerDidEnd::无法识别的选择器已发送到实例0x281c70’
提前谢谢你
- (IASKAppSettingsViewController*)appSettingsViewController {
if (!appSettingsViewController) {
appSettingsViewController = [[IASKAppSettingsViewController alloc] initWithNibName:@"IASKAppSettingsView" bundle:nil];
appSettingsViewController.delegate = self;
}
return appSettingsViewController;
}
-(IBAction)selectSettings {
UINavigationController *aNavController = [[UINavigationController alloc] initWithRootViewController:self.appSettingsViewController];
//[viewController setShowCreditsFooter:NO]; // Uncomment to not display InAppSettingsKit credits for creators.
// But we encourage you not to uncomment. Thank you!
self.appSettingsViewController.showDoneButton = YES;
[self presentModalViewController:aNavController animated:YES];
[aNavController release];
}
-(NSDictionary *)intialDefaults {
NSArray *keys = [[[NSArray alloc] initWithObjects:kPicture, nil] autorelease];
NSArray *values= [[[NSArray alloc] initWithObjects: @"none", nil] autorelease];
return [[[NSDictionary alloc] initWithObjects: values forKeys: keys] autorelease];
}
-(void)setValuesFromPreferences {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults registerDefaults:[self intialDefaults]];
NSString *picturePreference= [userDefaults stringForKey:kPicture];
if([picturePreference isEqualToString:@"google"]) {
[self getUpcoming:@"http://www.google.ca"];
} else
if ([picturePreference isEqualToString:@"stackoverflow"]) {
[self getUpcoming:@"http://www.stackoverflow.com"];
} else {
[self getUpcoming:@"http://www.yahoo.com"];
}
}
-(void)getUpcoming:(id) hello {
NSURL *url= [NSURL URLWithString:hello];
NSURLRequest *requestURL= [NSURLRequest requestWithURL:url];
[web loadRequest:requestURL];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
web.hidden=NO;
[spinner stopAnimating];
[load_message dismissWithClickedButtonIndex:0 animated:TRUE];
pic1.hidden=YES;
}
-(void) loadMethod {
load_message = [[UIAlertView alloc] initWithTitle:@"Loading..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
spinner= [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(135.0, 60.0);
[load_message addSubview:spinner];
[load_message show];
[spinner startAnimating];
[self performSelector:@selector(setValuesFromPreferences) withObject:nil afterDelay:0.0];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIBarButtonItem *settingButton= [[UIBarButtonItem alloc]
initWithTitle:@"Settings"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(selectSettings)];
self.navigationItem.rightBarButtonItem = settingButton;
web.hidden=YES;
pic1.hidden=NO;
}
- (void) viewDidAppear:(BOOL)animated {
[self loadMethod];
}发布于 2012-01-16 13:30:10
你实现InAppSettingKit委托了吗?将它添加到上面的当前类中
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController *)sender
{
// dismiss the view here
[self dismissModalViewControllerAnimated:YES];
// do whatever you need to do
}https://stackoverflow.com/questions/8875805
复制相似问题