TAILIEUCHUNG - iOS 5 Programming Cookbook phần 3

Tất cả những gì bạn thực sự cần phải làm bây giờ là để cung cấp nội dung mô hình dữ liệu (Model Controller) và bạn đi. Nếu bạn cần để tùy chỉnh màu sắc và hình ảnh trong các bộ điều khiển xem của bạn, chỉ cần làm như vậy bằng cách sử dụng giao diện Builder để sửa đổi các tập tin. | synthesize window _window synthesize rootViewController 3. Now find the application didFinishLaunchingWithOptions method of the app delegate inside the implementation .m file and instantiate the view controller and add it to our window - BOOL application UIApplication application didFinishLaunchingWithOptions NSDictionary launchOptions UIWindow alloc initWithFrame UIScreen mainScreen bounds makeKeyAndVisible RootViewController alloc initWithNibName nil bundle NULL addSubview return YES We add the view of the view controller to the window not the view controller itself. Now if you run your app on the simulator you will see a black screen. The reason is that our view controller s view doesn t have a background color yet so go to the file and find the viewDidLoad method which is in a state similar to this - void viewDidLoad super viewDidLoad Remove the comment lines from around this method - void viewDidLoad super viewDidLoad Now let s set the background color of our view controller s view to white - void viewDidLoad super viewDidLoad 162 Chapter 2 Implementing Controllers and Views UlColor whiteColor Go ahead and run the app on the simulator. You will now see a plain white view on the screen. Congratulations you just created a view controller and now you have access to the view controller and its view object. While creating the view controller Figure 2-26 if you had selected the With XIB for user interface checkbox then Xcode would have also generated an .xib file for you. In such case we would have to load our view controller from that .xib file by passing the .xib file s full name to the initWithNibName parameter of the initWithNibName bun dle method of the view controller like so - BOOL application UIApplication application didFinishLaunchingWithOptions NSDictionary launchOptions UIWindow alloc initWithFrame UIScreen

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.