Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13476] iOS 5: Image resize broken

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2013-04-11T20:53:40.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 08 API, 2013 Sprint 08, Release 3.2.0
ComponentsiOS
Labelsn/a
ReporterMartin Guillon
AssigneeVishal Duggal
Created2013-01-02T11:27:43.000+0000
Updated2013-10-25T18:31:15.000+0000

Description

Since this commit: https://github.com/vishalduggal/titanium_mobile/commit/a5b7828d980a36d298cb48ecba79971426f6a162 The resize of background image for button has changed on iOS 5. It does not resize the center by stretching but by tiling it. Looking at the commit there should be a test for uisGreater than 5 but only for the respondToSelector which follows.

Comments

  1. Davide Cassenti 2013-04-05

    Can you post a sample code? Which version(s) of the SDK do work for you, and which ones don't?
  2. Martin Guillon 2013-04-06

    it s been fixed: https://github.com/vishalduggal/titanium_mobile/commit/5d8a5edcb48aba8ed2580bfb4edc5b850f980ebc But if I may it s 2 "if" when only one was necessary Just test for the method and not ios5 and you are good
  3. Daniel Sefton 2013-04-06

    Resolved as fixed.. I doubt we'll have time to change if statements for the sake of cleanliness, as long as it works. Not sure what you meant by "Just test for the method and not ios5 and you are good".
  4. Martin Guillon 2013-04-07

    I get it s not a priority and i did it in my branch, so i am good ;) In the code we have 2 nested if case
       if ([TiUtils isIOS5OrGreater]) {
       ...
           if ([theImage respondsToSelector:@selector(resizableImageWithCapInsets:resizingMode:)]) {
                ...
                stretchableImage = [[theImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right) resizingMode:1] retain];
           }
           else {
           ...
           stretchableImage = [[theImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)] retain];
           }
       }
       else {
       ...
       stretchableImage = [[theImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)] retain];
       }
       ...
       
    There s redondancy you can simply do it that way
       if ([theImage respondsToSelector:@selector(resizableImageWithCapInsets:resizingMode:)]) {
          ...
          stretchableImage = [[theImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right) resizingMode:1] retain];
       }
       else {
          ...
          stretchableImage = [[theImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)] retain];
       }
       ...
       
  5. Vishal Duggal 2013-04-11

    This is the inner if condition right now with all the calculation in the outer if loop.
                   if ([theImage respondsToSelector:@selector(resizableImageWithCapInsets:resizingMode:)]) {
                       //1 = UIImageResizingModeStretch
                       stretchableImage = [[theImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right) resizingMode:1] retain];
                   }
                   else {
                       stretchableImage = [[theImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)] retain];
                   }
       
       
  6. Martin Guillon 2013-04-12

    Yes Vishal but you dont need the ios5 test on top of it

JSON Source