PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
04/17/14 12:45 AM (10 years ago)

Adding a UITextField to a screen

Hi folks, I'm trying to add this UI element to a screen. I'm putting it into the plugin though I'm considering moving it to BT_viewController but pointing to teh plugin screen. Not sure if either way is better. Anyway, the first three lines are throwing "Expected identifier or '(' " errors and I'm not sure why. Does anyone have any ideas? (This isn't my strong suit...) UITextField *myTextField = [[[UITextField alloc] initWithFrame:CGRectMake(10, 100, 300, 30)]; myTextField.keyboardType(UIKeyboardType.Default); myTextField.returnKeyType(UIReturnKeyType.Default); app.getBT_ViewController().getView().addSubview(myTextField); [self.view addSubview:myTextField]; Thanks! Paddy
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/17/14 05:51 AM (10 years ago)
When you call a method, you shouldn't use parentheses - you should use brackets. When you assign a value, you should use an equal sign. So: myTextField.keyboardType = UIKeyboardTypeDefault; myTextField.returnKeyType = UIReturnKeyTypeDefault; Delete this: app.getBT_ViewController().getView().addSubview(myTextField); Use the autocomplete function of XCode. It's your friend
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/17/14 05:50 PM (10 years ago)
Ah, the penny drops. Thanks Chris, much appreciated. (And it did need to go into the BT_viewController with a conditional for the screens I want it on.) Cheers Paddy
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.