小编A3O*_*A3O的帖子

将我的应用程序带到Objective-C的前台

由于位置服务,我的应用程序必须在后台运行很长时间(也).当满足某个条件时,应用程序必须移动到前台.我能够在后台运行我的应用程序并手动将其带到前面.阅读这个问题,我对如何通过代码将我的应用程序移到前台感到困惑.

它必须在if语句中但是从这里做什么?

iphone objective-c ios

0
推荐指数
1
解决办法
840
查看次数

NSNotification失败....为什么?

我正在努力让NSNotifications发挥作用.此刻,没有成功.

在我的appDelegate.m文件中,我有:

[[NSNotificationCenter defaultCenter] postNotificationName:@"first" object:nil];
Run Code Online (Sandbox Code Playgroud)

在我的mainViewController.m中,在viewDidLoad方法中我有

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(firstRun)name:@"first" object:nil];
Run Code Online (Sandbox Code Playgroud)

并创建了一个方法(在mainViewController.m中也是如此):

-(void) firstRun:(NSNotification *) notification
{
        NSLog(@"This works!");
}
Run Code Online (Sandbox Code Playgroud)

但是,在运行应用程序时,我在日志中看不到任何输出.

我的代码出了什么问题?请指教.

objective-c nsnotificationcenter ios

-1
推荐指数
1
解决办法
236
查看次数

如何解除代码生成的子视图?

在我的项目中,我想在第一次启动应用程序时显示第一个运行视图.为此,我在我的mainViewCntroller.m中添加了一个UIView.为了忽略这个(重叠)视图,我在视图上放了一个名为acceptButton的按钮.我必须添加什么代码才能从堆栈中删除此视图?

我做错了什么?

这是我的代码:

- (void) firstRun {
if (((AppDelegate*)[UIApplication sharedApplication].delegate).firstRun)
{
    CGFloat height = [[UIScreen mainScreen] bounds].size.height;
    CGFloat width = [[UIScreen mainScreen] bounds].size.width;

    NSLog(@"%f", height);

    CGRect myFrame = CGRectMake(0, 0, width, height);
    UIView *myView = [[UIView alloc] initWithFrame:myFrame];
    myView.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
    myView.tag = 12345;
    [self.view addSubview:myView];

    // Create a ScrollView and a label
     UIScrollView *discScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(20.0f, 0.0f, self.view.frame.size.width - 20, self.view.frame.size.height -70)];
     discScroll.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

     UILabel *discLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];
     discLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth …
Run Code Online (Sandbox Code Playgroud)

objective-c uiviewcontroller uiview ios

-1
推荐指数
1
解决办法
4046
查看次数