我有一个NSNumbers 数组,例如:10015,12313,10016
我想检查数组是否包含我在searchBar中输入的整数.
我的代码:
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:@"SELF CONTAINS[c] %d", [searchText intValue]];
self.searchResults = [newArr filteredArrayUsingPredicate:resultPredicate];
Run Code Online (Sandbox Code Playgroud) 我有一个UIAlertView带UITextView.在ViewDidAppear我做[textView setText:]一个大的文本,但该警报显示一个空的TextView的,只有经过我摸TextView的滚动,显示的文本.
我应该怎么做才能使文本出现在警报的textView中,而不是滚动它来"刷新"它?
谢谢!
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
av = [[UIAlertView alloc]initWithTitle:@"Terms of Service" message:@"\n\n\n\n\n\n\n" delegate:self cancelButtonTitle:@"Disagree" otherButtonTitles:@"Agree",nil];
UITextView *myTextView = [[UITextView alloc] initWithFrame:CGRectMake(12, 50, 260, 142)];
[myTextView setTextAlignment:UITextAlignmentCenter];
[myTextView setEditable:NO];
myTextView.layer.borderWidth = 2.0f;
myTextView.layer.borderColor = [[UIColor darkGrayColor] CGColor];
myTextView.layer.cornerRadius = 13;
myTextView.clipsToBounds = YES ;
[myTextView setText:@"LONG LONG TEXT"];
[av addSubview:myTextView];
[myTextView release];
[av setTag:1];
[av show];
Run Code Online (Sandbox Code Playgroud)
}
我有以下代码,每次用户单击特定按钮时都会运行 1 分钟。
timer = [[NSTimer alloc]init];
timer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果应用程序处于后台模式,如何保持其运行,以便计时器仍然继续工作?
提前致谢!