Answer to the question of ILeW with an article about what the real, attaching such as notifications and delegates work. Using a pattern we see first how the delegate pattern:

An object in search of a delegate
Answer to the question of ILeW with an article about what the real, attaching such as notifications and delegates work. Using a pattern we see first how the delegate pattern:

An object in search of a delegate
The simulator iPhones / iPad Xcode allows you to simulate the double tap the Alt key is pressed. This is useful to simulate the function of Pinch, that used to enlarge or scroll Keep away content in the view with objects or UIWebView . Well, some of you have noticed that the simulation of the "two fingers" proceeds in a symmetrical manner always starting from the center of the screen. To move this "center" is also just hold down the SHIFT key.
, sono molto utilizzati nello sviluppo di applicazioni per Apple iPhone. The object of UIImage , along with UIImageView , are widely used in developing applications for Apple iPhone. Here is some useful code snippet-make a set of common processing:
1 2 3 4 5 6 7 8 9 10 11 12 | UIImage * ) combineImage : ( UIImage * ) imageA imageB : ( UIImage * ) imageB { - (UIImage *) combineImage: (UIImage *) Imageo imageB: (UIImage *) {imageB ; UIGraphicsBeginImageContext (imageA.size); CGRectMake ( 0 , 0 , imageA.size.width, imageA.size.height ) ] ; [Imageo drawInRect: CGRectMake (0, 0, imageA.size.width, imageA.size.height)]; CGRectMake ( 0 , 0 , imageB.size.width, imageB.size.height ) ] ; [ImageB drawInRect: CGRectMake (0, 0, imageB.size.width, imageB.size.height)]; UIGraphicsGetImageFromCurrentImageContext ( ) ; UIImage * combinatedImage UIGraphicsGetImageFromCurrentImageContext = (); UIGraphicsEndImageContext (); combinatedImage return; } |
potremmo aver necessità di personalizzare la grafica dei titoli delle sezioni, come California o New York dell'esempio qui sotto. When we use a UITableView style Grouped we may need to customize the layout of section titles, such as California or New York the example below.

To do so, please use the following code, placing it in the delegate, ie in the class that responds to the protocol UITableViewDelegate :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | / / Returns View my custom, in this case an object / / Type UILabel UIView * ) tableView : ( UITableView * ) tableView - (UIView *) tableView: (UITableView *) tableView NSInteger ) section { viewForHeaderInSection: (NSInteger) section { [ [ [ UILabel alloc ] initWithFrame : CGRectZero ] autorelease ] ; UILabel * label = [[[UILabel alloc] initWithFrame: CGRectZero] autorelease]; UIFont boldSystemFontOfSize : 20 ] ; label.font = [UIFont boldSystemFontOfSize: 20]; label.textAlignment = UITextAlignmentCenter; UIColor blackColor ] ; label.shadowColor = [UIColor blackColor]; 1 , 1 ) ; label.shadowOffset CGSizeMake = (1, 1); "Sezione" ; // Sostituire con un array come al solito Label.Text @ = "Section", / / Replace with an array as usual UIColor whiteColor ] ; label.textColor = [UIColor whiteColor]; UIColor clearColor ] ; label.backgroundColor = [UIColor clearColor]; ; label.opaque = NO; return label; } / / We must also support this message does not work otherwise CGFloat ) tableView : ( UITableView * ) tableView - (CGFloat) tableView: (UITableView *) tableView NSInteger ) section { heightForHeaderInSection: (NSInteger) section { ; return 44; } |
It is also important to include heightForHeaderInSection , will not work.
o UIImageView , ho utilizzato per inizializzare il frame CGRectZero che corrisponde a CGRectMake(0,0,0,0) . In the creation of our UILabel , which might also be wanting a more complex object like a UIView or UIImageView , I used to initialize the frame CGRectZero corresponding to CGRectMake(0,0,0,0) .
CGRectMake() is a function (actually an inline # define) used a lot especially when you create graphics objects from code or user interface. o UIImageView . CGRectMake() restituisce una struct (struttura di tipo) CGRect : Its use is therefore often associated initialization components of UIKit , but also to simple UIView or UIImageView . CGRectMake() returns a struct (structure type) CGRect :
1 2 3 4 5 | struct {CGRect CGPoint origin; CGSize size; }; typedef struct CGRect CGRect; |
: Which in turn is composed of two different struct CGPoint and CGSize :
1 2 3 4 5 6 7 8 9 10 11 12 13 | struct {CGPoint CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint; / * Sizes. * / struct {CGSize CGFloat width; CGFloat height; }; typedef struct CGSize CGSize; |
. That, in turn, again, contain types CGFloat or type float . If we analyze the code of CGRectMake () are:
1 2 3 4 5 6 7 8 | CG_INLINE CGRect CGRectMake (CGFloat x, y CGFloat, CGFloat width, height CGFloat) { CGRect rect; y; rect.origin.x = x, y = rect.origin.y; height; rect.size.width = width, height = rect.size.height; return rect; } |
It follows, therefore, that this piece of code:
1 2 3 4 | [ UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton gbutton * = [UIButton buttonWithType: UIButtonTypeRoundedRect]; 12 , 409 , 100 , 40 ) ; gbutton.frame = CGRectMake (12, 409, 100, 40); @ "Press" forState : UIControlStateNormal ] ; [Gbutton setTitle: @ "Press" Forst: UIControlStateNormal]; gbutton ] ; [MainWindow addSubview: gbutton]; |
It could rightly be written as:
1 2 3 4 | [ UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton gbutton * = [UIButton buttonWithType: UIButtonTypeRoundedRect]; CGRect ) { 12 , 409 , 100 , 40 } ; gbutton.frame = (CGRect) {12, 409, 100, 40}; @ "Press" forState : UIControlStateNormal ] ; [Gbutton setTitle: @ "Press" Forst: UIControlStateNormal]; gbutton ] ; [MainWindow addSubview: gbutton]; |
Just to speed things up 'the code is running ... ![]()
creato. I want to show how you can, easily and quickly extend a class UIView in a way that responds to a new initialization method contains additional code to customize the object UIView created. As some of you probably know, Objective-C does not support a single manufacturer as in other object oriented languages (such as Adobe ActionScript or PHP 5). It 'can, in fact, create an instance of a class manually invoking different manufacturers (virtually infinite). . Normally we are used to create objects UIView with the classic initWithFrame . But imagine you want to create a new class of visual objects, from a UIView , with some additions, such as a built-in label. . Basically what we want is that instantiating our object it creates, as well as the UIView , an object of type UILabel . For example we might want to get to the end:
1 | [ [ ViewLabel alloc ] initWithLabelDefine : CGRectMake ( 0 , 0 , 320 , 80 ) label : @ "Ciao" ] ; ViewLabel vl = * [[ViewLabel alloc] initWithLabelDefine: CGRectMake (0, 0, 320, 80) label: @ "Hello"]; |
: To do this simply create a new class of type UIView and call ViewLabel :
1 2 3 4 5 6 7 8 9 10 11 12 13 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | / / / / ViewLabel.m / / # Import "ViewLabel.h" @ Implementation ViewLabel id ) initWithFrame : ( CGRect ) frame { - (Id) initWithFrame: (CGRect) frame { self = [ super initWithFrame : frame ] ) { if (self = [super initWithFrame: frame]) { / / Initialization code } return self; } / / / / Our new initializer / / id ) initWithLabelDefine : ( CGRect ) frame label : ( NSString * ) labelDefine { - (Id) initWithLabelDefine: (CGRect) frame label: ( NSString *) {labelDefine self = [ super initWithFrame : frame ] ) { if (self = [super initWithFrame: frame]) { / / Here you can decide what to do, I for / / I got the same frame security in the past / / Input but I reset the x and y ; frame.origin.x = 0; ; frame.origin.y = 0; UILabel alloc ] initWithFrame : frame ] ; internalLabel = [[UILabel alloc] initWithFrame: frame]; internalLabel.text = labelDefine; internalLabel ] ; [Self addSubview: internalLabel]; ; [InternalLabel release]; } return self; } void ) drawRect : ( CGRect ) rect { - (Void) drawRect: (CGRect) rect { / / Drawing code } void ) dealloc { - (Void) dealloc { ; [Super dealloc]; } @ End |
At the time of the creation of our new class, we could use:
1 | [ [ ViewLabel alloc ] initWithLabelDefine : CGRectMake ( 0 , 0 , 320 , 80 ) label : @ "Ciao" ] ; ViewLabel vl = * [[ViewLabel alloc] initWithLabelDefine: CGRectMake (0, 0, 320, 80) label: @ "Hello"]; |
As indicated in the post Apple iPhone SDK 3.0: first incompatibility of the Apple SDK 3.0 show different behaviors with respect to release 2.2.1. Support service for developers gave me the answer, and then the solution to the problem. . The answer was that the technical support [UIButton buttonWithType:] already called - inside - the initWithFrame . It follows that, according to the technical support, writing:
Latest Comments
Giovambattista Fazioli : @ paso: absolutely. Simply identifying the field [cci] input [/ cci] you want to ...
paso : Hello I would like to request a service, you can use the datepicker with cform7 I spiegp best I can implement ...
Simon : It annoys disturbed again and use that space for these things ... however it does not work ...
Giovambattista Fazioli : @ Barbara: If you mean the bottom to start writing down what it depends on where ...
Barbara : Hello, is very interesting but how do you write at the bottom instead of the above? Thanks