Thursday, 17 January 2013

To create button dynamically and sending message .


UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self
               action:@selector(oncall)
     forControlEvents:UIControlEventTouchDown];
    [button setTitle:@"SUBMIT" forState:UIControlStateNormal];
    button.frame = CGRectMake(100.0, 210.0, 100, 40.0);
    [self.view addSubview:button]; 



Note: When we call a method in IOS we say sending message not calling. because we we can send  message either objects are valid or not .. it may crash when user clicked on the button if calling method is not present but it means you can write methods name even though they are not presents.