任何人都可以帮助Objective C新手吗?

时间:2010-12-15 22:30:39

标签: objective-c

我觉得我完全不在我的深处,我对目标c非常新,但已被要求设计一个iPhone应用程序作为我的单一课程的一部分。我之前设计了一个sinple测验,但我希望设计一个更高级的测验游戏,有3个级别(每个级别将有不同的测验)。

我不知道如何使用UIViews,我在线尝试了一个教程来帮助我编写导航控制器。它允许我进入子视图1,2或3的3个选项。所有子视图都有相同的屏幕,有一个标签和一个按钮。

到目前为止我有3个类,RootViewController,BasicNavigationAppDelegate和SubViewOneController。

我真的根本不懂代码,熟悉Java,但这个目标c并不像它。有人可能需要花一点时间帮助一个遇险的人,并通过使用导航控制器显示我的水平来解释我是否正确这样做?当我检查xib接口文件时,我没有看到按钮或标签,或者不知道在哪里添加测验界面对象!我真的很困惑这一切。有人可以帮忙吗?

3 个答案:

答案 0 :(得分:1)

您应该在google中搜索示例源代码,并查看如何处理某些视图。有很多方法可以处理视图,无论是通过UINavigationController,UITabBarController等。如果你是Objective-C的新手,那么你真的不会得到这个问题的答案,它将指导你究竟做什么

Interface Builder + View Controllers

这对你来说很好:View Controllers Programming Guide

(Apple's) View Controller Reference Guide

Some Code Samples

Getting Started Sample Code

答案 1 :(得分:0)

对于3级测验,UINavigationController绝对是一个选项。

如果您需要了解如何使用类,在xcode中键入其名称,然后按-alt-并双击类名,这将显示一个简短的描述,带有两个图标,一个会带你到头文件,另一个到文档。

要向nib / xib文件中添加元素,您需要打开库窗口,在那里您可以找到使用按钮的标签,按钮等,您需要在头文件中定义一个动作,并勾选在IB中,为了能够与代码中的UIElements进行交互,您需要在头文件中设置出口,并将它们连接到IB中。

您需要决定的是,您将如何呈现问题,还将取决于答案是真/假,多项选择还是文本输入。

如果您不熟悉obj-c和xcode,那么从http://www.pragprog.com之类的人那里购买电子书可能是值得的。比尔·达德尼(Bill Dudney)在那里有一部iPhone,非常好(我相信他现在适合苹果使用。)


对于标准滑出转换,您可以使用此功能。     //你可能想把它称为level1NavBarItemWasPushed:而不是      - (IBAction)lvl1pushNavBarItem:(id)sender {         //创建AnswersViewController类的实例。         AnswersViewController * level1AnswersVC = [[Level1AnswersViewController alloc] init];

    //pass it some kind of identifier so it can tell which quiz/question it is dealing with and pull in the answers, so that you can reuse the view
    [level1AnswersVC setAnswersObject:<<insert object dictionary here>>];

    //push the view controller onto the navigationController's view stack 
    [self.navigationController pushViewController:level1AnswersVC animated:TRUE];

    //pushing it onto the view stack has given it +1 retain, so we can now release it without worrying about it disappearing prematurely.
    [level1AnswersVC release];
 }

对于页面翻转过渡,您可以使用此功能。

- (IBAction)lvl1pushNavBarItem:(id)sender {
    //create instance of AnswersViewController class.
    AnswersViewController *level1AnswersVC= [[Level1AnswersViewController alloc] init];

    //pass it some kind of identifier so it can tell which quiz/question it is dealing with and pull in the answers, so that you can reuse the view
    [level1AnswersVC setAnswersObject:<<insert object dictionary here>>];

    //set the current viewController as the delegate, so that it can call back to us when its done        
    level1AnswersVC.delegate = self;

    //set the modal transition style
level1AnswersVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

    //show answers as modal view, which has been setup to use the page flip transition.
[self presentModalViewController:level1AnswersVC animated:YES];

    //pushing it onto the view stack has given it +1 retain, so we can now release it without worrying about it disappearing prematurely.
    [level1AnswersVC release];
 }

答案 2 :(得分:0)

我建议 Head First iPhone Development: A Learner's Guide to Creating Objective-C Applications for the iPhone 。在几章内,您将了解构建此应用程序所需的一切,您将真正理解您正在做的事情。

(我不知道作者或出版商,我认为这是一本很快就能快速上手的好书。)