所以,我能够创建一个填充表的字段的数组,但是在创建主字段下面出现的子文本时遇到了麻烦.我目前有:
- (void)viewDidLoad {
[super viewDidLoad];
listOfForms = [[NSMutableArray alloc] init];
[listOfForms addObject:@"First Form"];
}
Run Code Online (Sandbox Code Playgroud)
然后:
NSString *cellValue = [listOfDAForms objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
Run Code Online (Sandbox Code Playgroud)
在cellForRowAtIndexPath部分中.为什么我不能添加:
listOfNames = [[NSMutableArray alloc] init];
[listOfNames addObject:@"Named Form"];
Run Code Online (Sandbox Code Playgroud)
和
NSString *cellSubscript = [listOfNames objectAtIndex:indexPath.row];
cell.detailTextLabel.text = cellSubscript;
Run Code Online (Sandbox Code Playgroud)
为了使小子视图工作?我究竟做错了什么?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
// Return YES if incoming orientation is Portrait
// or either of the Landscapes, otherwise, return NO
return (toInterfaceOrientation == UIInterfaceOrientationPortrait) || UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)
'||'是什么 这意味着什么
我创建了一个新的基于窗口的项目,无法弄清楚为什么它没有做任何事情.最后我在didFinishLaunching之后立即放置了一个NSLog,当我运行它时它永远不会被记录.这是我写的所有代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"didFinishLaunching");
// Get the device object and turn proximity monitoring on
UIDevice *d = [UIDevice currentDevice];
[d setProximityMonitoringEnabled:YES];
// Get the NSNotificationCenter object
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Sign up to receive notifications when the proximity state changes
[nc addObserver:self selector:@selector(proximityChanged:) name:UIDeviceProximityStateDidChangeNotification object:d];
NSLog(@"Observing...");
[self.window makeKeyAndVisible];
return YES;
}
- (void)proximityChanged:(NSNotification *)note {
// Print out the changes of proximity state
NSLog(@"Proximity Changed: %d", [[note object] proximityState]);
}
Run Code Online (Sandbox Code Playgroud)
这是我写的全部内容,当我在模拟器或设备上运行时,没有记录任何内容.有什么想法吗?
我不明白为什么这不起作用:
[abc = ([def intValue] - 71) * 6];
Run Code Online (Sandbox Code Playgroud)
'*'应该是进行乘法的可行方法,'abc'被定义为NSInteger.('def'是一个NSString)
我找到了一个页面(http://itunes.apple.com/linkmaker)来获取特定页面的iTunes网址,我认为应该将用户从我的应用程序中导出并进入应用程序商店中的相应页面.
我从来没有做过这个或任何其他UIWebView的东西,但经过一些搜索,我发现了一些我认为可以使用UIApplication.h的代码.
我的代码是:
#import <UIApplication.h>
//...in a tableView....
case 8:
- (BOOL)openURL:(NSURL *) http://itunes.apple.com/us/app/lockbox-pro/id288460603?mt=8&uo=4;
break;
Run Code Online (Sandbox Code Playgroud)
openURL有一个错误,说它是未声明的 - 但我导入了UIApplication.h文件.然后我看到UIApplication导入也有错误.我不认为我想使用UIWebView,因为根据我的理解,这会打开应用程序本身的URL - 我想将用户引导到App Store.我哪里错了?
编辑:好的,我把它改成了一个简单的按钮,它应该关闭应用程序并将用户带到itunes页面:
- (IBAction) pressedFull {
[[UIApplication sharedApplication] openURL:[NSURL urlWithString:@"http://www.google.com"]];
Run Code Online (Sandbox Code Playgroud)
}
我在IB中将其链接 - 当用户点击它时,它仍然会崩溃应用程序.
我想在应用程序关闭或在后台运行一段时间(比如说5分钟)时,消除保存到NSUserDefaults所有字段中的所有变量.
我试图在applicationDidFinishLaunching的app委托中添加一行,如下所示:
if (UIApplicationStateBackground == TRUE) {
NSUserDefaults *profiles = [NSUserDefaults standardUserDefaults];
[profiles setObject:nil forKey:@"name1"];
[profiles synchronize];
}
Run Code Online (Sandbox Code Playgroud)
我还将这部分添加到applicationWillTerminate中:
NSUserDefaults *profiles = [NSUserDefaults standardUserDefaults];
[profiles setObject:nil forKey:@"name1"];
[profiles synchronize];
Run Code Online (Sandbox Code Playgroud)
这似乎都不起作用,我不知道如何设置'如果5分钟超过应用程序在后台,删除NSUserDefaults变量'的条件 - 任何帮助?
目前,我对所有不同视图的标题都正确呈现:
self.title = self.viewedCategory.title;
Run Code Online (Sandbox Code Playgroud)
但是,由于数据结构,主根视图没有标题.我试着用这个解决它:
if (self.viewedCategory.title == Nil) {
self.title = @"Root View Title";
} else {
self.title = self.viewedCategory.title;
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用,我不知道为什么.我也尝试'== @""'认为它可能是一个没有任何字符的字符串,但这也不起作用.
思考?