0

Will the app containing this warning pass App Store review?

With the code, it gets actually rendered in iPhone simulator, but how should I remove the above-mentioned warning in Xcode?

EDIT 20 September 2011:

I will post the code that removes this warning someday.

EDIT 9 October 2011:

Here is my solution, as I could not find any other better and easier solution:

    UIView *extrablue = [[UIView alloc] initWithFrame:CGRectMake(250,0,80,40)];
    extrablue.backgroundColor = RGBCOLOR (95,95,95);
    [self.view addSubview:extrablue];
    mySearchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 250, 40)];
    //[mySearchBar setContentInset: UIEdgeInsetsMake(5,0,5,75)];
    mySearchBar.placeholder = @"Search a term here ... ";
    mySearchBar.backgroundColor = RGBCOLOR (95,95,95);
    mySearchBar.delegate = self;
    //[mySearchBar sizeToFit];
    mySearchBar.autocorrectionType = UITextAutocorrectionTypeNo;
    [mySearchBar setAutocapitalizationType:UITextAutocapitalizationTypeNone];
    [self.view addSubview: mySearchBar];

2 Answers 2

2

UISearchBar does not contain the property contentInset - this is a property of UIScrollView. If your code is asking a UISearchBar to change its contentInset then this is a coding error, and should be removed.

If you need further help removing this, then some additional code would be useful.

0
1

I discovered that UISearchBar responds to the setContentInset: method (tested on iOS 5.0.1).

This result in a sofisticated approach involving NSInvocation:

    if([aSearchBar respondsToSelector:@selector(setContentInset:)]) {
        SEL aSelector = NSSelectorFromString(@"setContentInset:");
        NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[aSearchBar methodSignatureForSelector:aSelector]];
        [inv setSelector:aSelector];
        [inv setTarget:aSearchBar];
        UIEdgeInsets anInsets = UIEdgeInsetsMake(5, 0, 5, 35);
        [inv setArgument:&anInsets atIndex:2]; //arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
        [inv invoke];
    }

The above code resizes the contentInset of the UISearchBar (effectively UITextField) using the CGRect indicated in the anInsets parameter.

the parent if-statement (respondsToSelector:) save yourself from changes of this behaviour in new versions of iOS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.