IOS4 note 12 (Chapter 11)

Cocoa Events

None of your code runs until Cocoa calls it. The art of Cocoa programming consists largely of knowing when and why Cocoa will call your code. If you know this, you can put your code in the correct place, with the correct method name, so that your code runs at the correct moment, and your app behaves the way you intend.

 

Reasons for Events

User events

The user does something interactive, and an event is triggered directly. Obvious examples are events that you get when the user taps or swipes the screen, or types a key on the keyboard.

Lifetime events

These are events notifying you of the arrival of a stage in the life of the app, such as the fact that the app is starting up or is about to go into the background, or of a component of the app, such as the fact that a UIViewController’s view has just loaded or is about to be removed from the screen.

Functional events

Cocoa  is about  to do  something, and  turns  to you  in  case you want  to  supply (additional) functionality. I would put into this category things like UIView’s drawRect: (your chance to have a view draw itself) and UILabel’s drawTextInRect: (your chance to modify the look of a label).

Query events

Cocoa turns to you to ask a question; its behavior will depend upon your answer.For example, the way data appears  in a table (a UITableView)  is that whenever Cocoa needs a cell for a row of the table, it turns to you and asks for the cell.

 

Subclassing

A built-in Cocoa class may define methods that Cocoa itself will call and that you are invited (or required) to override in a subclass. Sometimes you know when the method will be called; at other times you don’t know or care exactly when the method is called, but you know that you must override it so that whenever it is called, your behavior, and not (merely) the default behavior, will take place.

For example, the UIView’s drawRect:. The built-in UIView implementation does nothing, so overriding drawRect: in a subclass is your only chance to dictate the full procedure by which a view draws itself. You don’t know exactly when this method will be called, and you don’t care; when it is, you draw, and this guarantees that  the view will always appear  the way you want  it  to.  (You never call drawRect: yourself; if some underlying condition has changed and you want the view to be redrawn, you call setNeedsDisplay and let Cocoa call drawRect: in response.)

For example, you must override loadView if your UIViewController creates its view in code, and you must create and assign it to this instance’s view property at this moment.(I’d probably call that a functional event, because your code has a specific job to do, namely, supply the view.) You may override viewDidLoad to perform additional initializations as your view is first loaded, whether it comes from a nib or you created it in loadView. Methods like view WillAppear: and viewDidDisappear: are called as your UIViewController’s view takes over the screen or is replaced on the screen by some other view; thus, viewWillAppear: is a moment to make sure that whatever happened while your view was offscreen is reflected in how it looks as it comes back onscreen. (Those are obviously lifetime events.)

A method like shouldAutorotateToInterfaceOrientation: is what I call a query event. It is passed an orientation parameter and returns a BOOL telling Cocoa whether your view can appear in that orientation. The default, if you don’t implement it, is that your view can appear only in portrait orientation. If you want this UIViewController’s view to appear in some other orientation, you’ll return YES for that orientation. If you return YES  for more  than one orientation and  the user  rotates  the device, you might  then receive messages like willRotateToInterfaceOrientation:duration: and willAnimateRotationToInterfaceOrientation:duration:, where you can customize what happens to the view as the orientation changes.

Even  further  up  the  inheritance  hierarchy,  you’ll  find  things  like  NSObject’s initialize class method. Every class that is actually sent a class method message (including instantiation) is first sent the initialize message, once. Thus, initialize can be overridden in order to run code extremely early in a class’s lifetime (before it even has an instance). Your project’s application delegate class is instantiated very early in the app’s lifetime, as the main nib loads, so its initialize can be a good place to perform very early app initializations, such as setting default values for any user preferences. For typical code, look at Apple’s Metronome example, in MetronomeAppDelegate.m. Observe that we test, as a matter of course, whether self really is the class in question; otherwise there is a chance that initialize will be called again (and our code will run again) if a subclass of this class is used.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: iOS 12可用的签名软件有很多选择。以下是其中一些常用的签名软件: 1. Cydia Impactor:这是一款非常受欢迎的签名工具,允许用户将未在App Store上架的应用安装到iOS设备上。使用Cydia Impactor,您可以签名任何经过开发者授权的应用,并将其安装到非越狱的iOS设备上。 2. AltStore:这是一款新兴的签名工具,它使用了一种创新的方法来签署应用程序,而不需要使用Apple Developer帐户。AltStore支持iOS 12及更高版本的操作系统,并通过Wi-Fi或USB连接提供签名。 3. TestFlight:这是由苹果官方提供的一种测试应用的工具,可允许开发人员将其测试版应用分发给特定用户进行测试。TestFlight只适用于开发人员和测试人员,并需要使用苹果开发者帐户进行签名和分发。 4. TutuApp:这是一个第三方应用商店,它提供了大量经过签名的应用程序供用户下载。TutuApp具有易于使用的界面,并支持免费和付费的应用程序下载。 5. AppValley:类似于TutuApp,AppValley是另一个提供签名应用程序的第三方应用商店。它提供了许多流行的应用程序,包括免费和付费的应用程序。 这是一些iOS 12可用的签名软件的例子。请注意,使用第三方签名软件有一定的风险,并且可能违反苹果的服务条款。因此,在使用这些签名软件之前,请确保了解并遵守相关法律和政策。 ### 回答2: iOS 12可用的签名软件有很多选择。以下是几个广泛使用的签名软件: 1. AltStore:这是一款自由开源的签名工具,它允许用户在iOS设备上安装和签名自己的应用程序。AltStore可用于无需越狱的设备,并使用Apple的开发者证书进行签名,以确保应用程序的安全性。 2. AppCake:这是一个流行的应用程序安装工具,允许用户安装IPAs文件并签名应用程序。它提供了一个简单易用的界面,并且支持iOS 12及更高版本。 3. Ignition:这是一个第三方应用商店,为用户提供了大量的iOS应用程序,用户可以直接从Ignition上下载并安装签名的应用程序。 4. 25PP:这是一款功能强大的应用安装工具,它允许用户安装带有签名的应用程序。25PP提供了大量的游戏和应用程序下载,适用于iOS 12及更高版本。 5. Panda Helper:这是一个提供签名应用程序的第三方应用商店,Panda Helper提供了大量的应用程序和游戏供用户下载和安装,而无需越狱设备。 这些签名软件都可在iOS 12及更高版本的设备上使用,它们提供了方便易用的界面和大量的应用程序供用户选择。用户可以根据自己的需求选择合适的签名软件来满足他们的应用程序安装需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值