Παρασκευή, 31 Αυγούστου 2012

How to use the Scroll Down (interface) at IOS - from stackoverflow


Here's another way to do this that you might like better:
  1. Set the File's Owner placeholder's custom class to your view controller subclass.
  2. Create the UIScrollView as a top-level object in your nib. Set its size to the screen size (320x460) or just turn on a status bar under "Simulated Metrics".
  3. Connect the scroll view's delegate outlet to File's Owner.
  4. Set the File's Owner's view outlet to the scroll view.
  5. Create a UIView as another top-level object in your nib. This will be your content view.
  6. Set the content view's size to 320x700.
  7. Create a strong (or retain, if not using ARC) outlet named contentView in your view controller (File's Owner) and connect it to the content view.
  8. Put your buttons in the content view.
  9. In your view controller's viewDidLoad, do this:
    - (void)viewDidLoad {
        [super viewDidLoad];
        [self.view addSubview:self.contentView];
        ((UIScrollView *)self.view).contentSize = self.contentView.frame.size;
    }
    
  10. In your view controller's viewDidUnload, do this:
    - (void)viewDidUnload {
        self.contentView = nil;
        [super viewDidUnload];
    }
    
share|edit|flag

Δευτέρα, 13 Αυγούστου 2012

Localizing Resources

copy paste from here


Don't localize numbers this way

Postby eaganj » Fri Jun 22, 2012 5:26 am
I just finished chapter 17 of the wonderful book, but this chapter feels weak, thin, and out of place. While the goal is certainly not to provide a complete overview of localization, it does provide one blaring example of what not to do when localizing numbers. In particular, the code that recommends showing the currency as :
CODE: SELECT ALL
NSString *currencySymbol = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencySymbol];
[[cell valueLabel] setText:[NSString stringWithFormat:@"%@%d", currencySymbol, [p valueInDollars]]];


will run and might appear correct, but is not. Not all regions display currencies in the same way. For example, while one might write $100 in the US, we write 100 (euro) in France. (Note: I had to write (euro) instead of the symbol in this message because of a text encoding bug.) Furthermore, some euro-zone regions write that as (euro) 100 (note the space). While completely understandable, writing (euro)100 just looks wrong. Fortunately, the NSNumberFormatter (which is just like the NSDateFormatter but for numbers) handles all these subtleties for us. So the above code should have been written as:
CODE: SELECT ALL
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setMaximumFractionDigits:0];
[[cell valueLabel] setText:[formatter stringFromNumber:[NSNumber numberWithInt:[p valueInDollars]]];