mardi 30 juin 2015

Library to read and write XML in Objective C

I am new in IPhone developer(objective c) and I would like to know what is the best library to write and read XML file.

Dynamically change UIView frame and subview frame

I came across a problem when dealing with dynamically changing UIView's and subview's frame. Here is my below code.

I have 3 UI elements created in xib. dynamicView, dynamicLabel and a button. On button click, I am trying to resize the UIView's frame and UILabel's frame.

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *dynamicLabel;
@property (weak, nonatomic) IBOutlet UIView *dynamicView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.dynamicLabel.backgroundColor = [UIColor redColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)changeFrame:(id)sender {
    self.dynamicView.frame = CGRectMake(2, 2, 60, 60);
    //[self.dynamicView addSubview:self.dynamicLabel];
    self.dynamicLabel.frame = CGRectMake(0, 0, 30, 20);
}
@end

As per the code, the expected result is, the dynamicView resize to (2, 2, 60, 60) and the dynamicLabel which is a subview of dynamicView, resize to (0, 0, 30, 20) with respect to its superview, dynamicView. But in the actual result, dynamicView is resized correctly and dynamicLabel is resized with respect to self.view. Attached the screenshot. enter image description hereenter image description hereenter image description here

What am I missing to bring the expected result?

iPHONE: QR CODE GENERATION

I have a requirement to generate a QR code image which will return a string when scanned. I have completed the scanning of QR code.I need some suggestion on how to generate a QR IMAGE in Iphone.

how to calculate difference between two times in different dates in iOS?

starttime= 23:00 pm end time= 5:00 am

I need the summing time of the start time to end time i am trying this code but it is not helpful to me

NSDateFormatter *formatter = [NSDateFormatter new];
        [formatter setDateFormat:@"HH"];

        NSDate *currentTime = [NSDate date];
        NSDate *openTime = [formatter dateFromString:start];
        NSDate *closeTime = [formatter dateFromString:end ];
        NSCalendar *calender = [NSCalendar currentCalendar];
        NSDateComponents *currentTimeComponents = [calender components:NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit fromDate:currentTime];
        NSDateComponents *openTimeComponents = [calender components:NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit fromDate:openTime];
        NSDateComponents *closeTimeComponents = [calender components:NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit fromDate:closeTime];

        NSUInteger currentTimeSeconds = currentTimeComponents.hour;

        NSUInteger openTimeSeconds = openTimeComponents.hour;

        NSUInteger closeTimeSeconds = closeTimeComponents.hour;

        if (currentTimeSeconds>openTimeSeconds && currentTimeSeconds<closeTimeSeconds) {
            NSLog(@"Time Between Open and Close Time %lu",(unsigned long)currentTimeSeconds);
        }

and it shows 0 hors. please help me some one? thanks in advance

UISplitViewController's preferredDisplayMode: incorrect behavior

I have a master-detail application (I created it using the Xcode template, and then I modified it a bit), and I'm trying to set the preferredDisplayMode property of UISplitViewController to obtain this behavior:

UISplitViewControllerDisplayMode.PrimaryOverlay: The primary view controller is layered on top of the secondary view controller, leaving the secondary view controller partially visible.

So the master view controller should initially be on top of the detail view controller, and it should be possible to dismiss it. I change this property in application:didFinishLaunchingWithOptions:, that's the full code:

 
// Inside application:didFinishLaunchingWithOptions:
// Override point for customization after application launch.
let rootViewController = window!.rootViewController as! UINavigationController
// The root view controller is a navigation controller that contains the split view controller
let splitViewController = rootViewController.viewControllers[0] as! UISplitViewController


let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem() splitViewController.delegate = self


splitViewController.preferredPrimaryColumnWidthFraction = 0.4 splitViewController.maximumPrimaryColumnWidth = 600 splitViewController.preferredDisplayMode = .PrimaryOverlay


return true

I have two problems: first, that's not the behavior that I obtain. The master view controller is hidden when the application launches, and if I click on the left bar button item to show the master, it rapidly appears and then disappears again. If I click it another time it appears without disappearing.
Second, I get a warning in the console:

2015-06-30 12:06:26.613 Presidents[29557:857547] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7b8be610>.

But I have no transitions in my code.

PS: It's from the book "Beginning Phone Development with Swift" by D. Mark, J. Nutting, K. Topley, F. Olsson, J. LaMarche, chapter 11.

Can I use the default image editor available in my iOS app?

I want to implement an image editing functionality similar to the native one provided by Apple in iPhones. Is it available to use inside the app? If not then is there any similar library available?

Testing IOS apps on ios devices made using IONIC and angularJS

I am making an app made using IONIC which i just want to test on my IOS device - not publish it to the app store. Do i still need a Apple developer account ( by paying $99 ) or is just a MAC with XCODE and IONIc installed enough?

I just want to test it on my device, not publish it to the app store.