Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15441] iOS: Fix Label sizing issues

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-10-17T17:52:37.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2013 Sprint 21, 2013 Sprint 21 API, Release 3.2.0
ComponentsiOS
Labelsn/a
ReporterVishal Duggal
AssigneeVishal Duggal
Created2013-10-09T19:04:47.000+0000
Updated2013-10-31T09:21:21.000+0000

Description

The Label proxy has some sizing issues and needs to be revisited. 1. ClipsToBounds is false so label text might overflow if content rect is larger than supplied bounds 2. Attributed Strings are displaying weird behavior on iOS7. Need to investigate and fix.

Comments

  1. Vishal Duggal 2013-10-12

    Test Case for Link Event. Needs iOS7 or above
       var win = Ti.UI.createWindow({
           backgroundColor: '#ddd',
           fullscreen:true,
           layout:'vertical'
       });
        
       var text =  'Longpress on any of the following:\n1.Appcelerator Titanium \n2.Android \n3.IOS ';
         
       var attr = Ti.UI.iOS.createAttributedString({
           text: text,
           attributes: [
               {
                   type: Ti.UI.iOS.ATTRIBUTE_LINK,
                   value: 'http://www.appcelerator.com/developers/',
                   range: [text.indexOf('Appcelerator Titanium'), ('Appcelerator Titanium').length]
               },
               {
                   type: Ti.UI.iOS.ATTRIBUTE_FONT,
                   value: {textStyle:Ti.UI.TEXT_STYLE_HEADLINE},
                   range: [text.indexOf('Appcelerator'), ('Appcelerator').length]
               },
               {
                   type: Ti.UI.iOS.ATTRIBUTE_FONT,
                   value: {textStyle:Ti.UI.TEXT_STYLE_SUBHEADLINE},
                   range: [text.indexOf('Titanium'), ('Titanium').length]
               },
               {
                   type: Ti.UI.iOS.ATTRIBUTE_LINK,
                   value: 'http://developer.android.com/',
                   range: [text.indexOf('Android'), ('Android').length]
               },
               {
                   type: Ti.UI.iOS.ATTRIBUTE_FONT,
                   value: {textStyle:Ti.UI.TEXT_STYLE_CAPTION1},
                   range: [text.indexOf('Android'), ('Android').length]
               },
               {
                   type: Ti.UI.iOS.ATTRIBUTE_LINK,
                   value: 'https://developer.apple.com/',
                   range: [text.indexOf('IOS'), ('IOS').length]
               },
               {
                   type: Ti.UI.iOS.ATTRIBUTE_FONT,
                   value: {textStyle:Ti.UI.TEXT_STYLE_CAPTION1},
                   range: [text.indexOf('IOS'), ('IOS').length]
               },
           ]
       });
       
       var label = Ti.UI.createLabel({
           backgroundColor: '#ccc',
           attributedString: attr,
       });
       
       label.addEventListener('link',function(e){
           alert(e.url);
       })
       
       
        
       
       var container1 = Ti.UI.createView({width:Ti.UI.SIZE,height:Ti.UI.SIZE,layout:'horizontal'});
       var b11 = Ti.UI.createButton({title:' W 200 '});
       var b12 = Ti.UI.createButton({title:' W 300 '});
       var b13 = Ti.UI.createButton({title:' W SIZE '});
       container1.add(b11);
       container1.add(b12);
       container1.add(b13);
       
       var container2 = Ti.UI.createView({width:Ti.UI.SIZE,height:Ti.UI.SIZE,layout:'horizontal'});
       var b21 = Ti.UI.createButton({title:' H 200 '});
       var b22 = Ti.UI.createButton({title:' H 300 '});
       var b23 = Ti.UI.createButton({title:' H SIZE '});
       container2.add(b21);
       container2.add(b22);
       container2.add(b23);
       
       var container3 = Ti.UI.createView({width:Ti.UI.SIZE,height:Ti.UI.SIZE,layout:'horizontal'});
       var b31 = Ti.UI.createButton({title:' Vert C '});
       var b32 = Ti.UI.createButton({title:' Vert T '});
       var b33 = Ti.UI.createButton({title:' Vert B '});
       container3.add(b31);
       container3.add(b32);
       container3.add(b33);
       
       var container4 = Ti.UI.createView({width:Ti.UI.SIZE,height:Ti.UI.SIZE,layout:'horizontal'});
       var b41 = Ti.UI.createButton({title:' Hor L '});
       var b42 = Ti.UI.createButton({title:' Hor C '});
       var b43 = Ti.UI.createButton({title:' Hor R '});
       container4.add(b41);
       container4.add(b42);
       container4.add(b43);
       
       //vertical = {center:0,top:1,bottom:2}
       //horizontal = {left:0,center:1,right:2}
       
       
       function clickHandler(e){
           if (e.source == b11) {
               label.width = 200;
           }    
           if (e.source == b12) {
               label.width = 300;
           }    
           if (e.source == b13) {
               label.width = Ti.UI.SIZE;
           }    
           if (e.source == b21) {
               label.height = 200;
           }    
           if (e.source == b22) {
               label.height = 300;
           }    
           if (e.source == b23) {
               label.height = Ti.UI.SIZE;
           }    
           if (e.source == b31) {
               label.verticalAlign = 0;
           }    
           if (e.source == b32) {
               label.verticalAlign = 1;
           }    
           if (e.source == b33) {
               label.verticalAlign = 2;
           }    
           if (e.source == b41) {
               label.textAlign = 0;
           }    
           if (e.source == b42) {
               label.textAlign = 1;
           }    
           if (e.source == b43) {
               label.textAlign = 2;
           }    
       }
       
       win.addEventListener('click',clickHandler);
       
       
       win.add(label);
       win.add(container1);
       win.add(container2);
       win.add(container3);
       win.add(container4);
       
       win.open();
       
  2. Vishal Duggal 2013-10-12

    Pull pending against master https://github.com/appcelerator/titanium_mobile/pull/4782
  3. Pedro Enrique 2013-10-17

    PR Merged into master
  4. Pragya Rastogi 2013-10-31

    Verified the fix with: OSX: 10.8.5 Xcode:5.0 Appcelerator Studio: 3.2.0.201310300145 SDK: 3.2.0.v20131029150357 acs:1.0.7 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processo:1.0.3 Device: iOS7(v7.0.3)-iPodTouch1

JSON Source