Monday 3 June 2013

Custom Split View with Animation

Hi All,

Hope you guys are doing well. In our last tutorial Custom Split View , we have discussed about creating a custom split view controller which will show both Master and Detail views at a time. I hope all of you guys have enjoyed that tutorial.

In this tutorial, we will add some UIView animations to the Custom Split View which we have created last week. If user applies a left gesture on the split view, it will hide the "Master View", if user applies a right gesture, it will show the "Master View".

Okay, lets start. Please open the Custom Split View class MLKSplitViewController class we have created. Create two gesture recognizers(one for left and other one for right) and a BOOL property to keep track the status of Master View. 

@property(nonatomic,retain) UISwipeGestureRecognizer *leftSwipeGestureRecognizer;

@property(nonatomic,retain) UISwipeGestureRecognizer *rightSwipeGestureRecognizer;

@property(nonatomic,assign) BOOL isMasterViewHidden;

Synthesize newly created properties :

@synthesize leftSwipeGestureRecognizer;
@synthesize rightSwipeGestureRecognizer;

@synthesize isMasterViewHidden;



In - (void)viewDidLoad method add the code to create gesture recognizers and hooking up with appropriate action methods :

    // Add left gesture recognizer
    self.leftSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(hideMasterView:)];
    [self.leftSwipeGestureRecognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
    [self.view addGestureRecognizer:leftSwipeGestureRecognizer];

    // Add right gesture recognizer
    self.rightSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(showMasterView:)];
    [self.rightSwipeGestureRecognizer setDirection:UISwipeGestureRecognizerDirectionRight];
    [self.view addGestureRecognizer:rightSwipeGestureRecognizer];

Now, implement the two actions for gesture recognizers and corresponding utility method :


#pragma mark -
#pragma mark - Gestures

- (IBAction)hideMasterView:(id)sender
{
    if( !isMasterViewHidden )
    {
        [UIView animateWithDuration:1.0 animations:^{
        
            [self setMasterViewFrame: CGRectMake(-MASTER_VIEW_WIDTH,0, MASTER_VIEW_WIDTH, self.view.bounds.size.height) detailViewFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
        }];
        
        isMasterViewHidden = YES;
    }
    
}

- (IBAction)showMasterView:(id)sender
{
    if( isMasterViewHidden )
    {
        [UIView animateWithDuration:1.0 animations:^{
                        
            [self setMasterViewFrame:CGRectMake(0,0, MASTER_VIEW_WIDTH, self.view.bounds.size.height) detailViewFrame:CGRectMake(MASTER_VIEW_WIDTH + SPLIT_GAP, 0, self.view.bounds.size.width - MASTER_VIEW_WIDTH - SPLIT_GAP, self.view.bounds.size.height)];
        }];
        
        isMasterViewHidden = NO;
    }
}

- (void)setMasterViewFrame:(CGRect)masterViewFrame detailViewFrame:(CGRect)detailViewFrame
{
    UIViewController *masterViewController = [self.viewControllers objectAtIndex:0];
    UIViewController *detailViewController = [self.viewControllers objectAtIndex:1];
    
    masterViewController.view.frame = masterViewFrame;
    detailViewController.view.frame = detailViewFrame;
}

Change the implementation of the - (void)layoutSubviews method according to the newly added utility method - (void)setMasterViewFrame:(CGRect)masterViewFrame detailViewFrame:(CGRect)detailViewFrame :

- (void)layoutSubviews
{
    if( !isMasterViewHidden )
    {
        [self setMasterViewFrame:CGRectMake(0,0, MASTER_VIEW_WIDTH, self.view.bounds.size.height) detailViewFrame:CGRectMake(MASTER_VIEW_WIDTH + SPLIT_GAP, 0, self.view.bounds.size.width - MASTER_VIEW_WIDTH - SPLIT_GAP, self.view.bounds.size.height)];
    }
}

We are done with the coding, lets see how output looks :
 Now apply a left swipe. See the output. "Master View" is hidden!!!!!!!!!!.
 Apply a right swipe. See the output. "Master View" is shown!!!!!!!!!!.
 Apply left and right swipes in landscape mode. Results are same as portrait!!!!!!


Hope you guys have enjoyed this tutorial about Custom Split View with Animation. Please feel free to add your comments and suggestions.

You can find source code here Source Code .



47 comments:


  1. Hi this is abinaya i am having 3 years of experience as a java developer and i am certified. i have knowledge on OOPS concepts in java but dont know indepth. After learning oracle will be enough to get a good career in IT with good package? and i crossed Oracle Training in Chennai website where someone please help me to identity the syllabus covers everything or not??

    Thanks, abinaya

    ReplyDelete
  2. Hi this is dwarakesh i am having 3 years of experience as a php developer and i am certified. i have knowledge on OOPS concepts in php but dont know
    indepth. After learning java will be enough to get a good career in IT with good package? and i crossed
    java training in Chennai website where someone please help me to identity the syllabus covers everything or not??

    thanks, dwarakesh

    ReplyDelete
  3. Hi this is dwarakesh i am having 3 years of experience as a php developer and i am certified. i have knowledge on OOPS concepts in php but dont know
    indepth. After learning java will be enough to get a good career in IT with good package? and i crossed
    java training in Chennai website where someone please help me to identity the syllabus covers everything or not??

    thanks, dwarakesh

    ReplyDelete

  4. hai If you are interested in asp.net training, our real time working.
    asp.net Training in Chennai.
    Asp-Net-training-in-chennai.html

    ReplyDelete

  5. Awesome Job oriented sharepoint training in Chennai is offered by our institue is mainly focused on real time and industry oriented. We provide training from beginner’s level to advanced level techniques thought by our experts.
    if you have more details visit this blog.
    SharePoint-training-in-chennai.html

    ReplyDelete
  6. great article!!!!!This is very importent information for us.I like all content and information.I have read it.You know more about this please visit again.
    sas Training in Chennai

    ReplyDelete
  7. Thanks for the best topic. Very useful information.
    load runner training in chennai

    ReplyDelete
  8. It 's amazing article and useful for developers
    iOS Online Training Hyderabad

    ReplyDelete
  9. Write more; that’s all I have to say. It seems as though you relied on the video to make your point. You know what you’re talking about, why waste your intelligence on just posting videos to your blog when you could be giving us something enlightening to read?
    Check out the best python training in chennai at SLA

    ReplyDelete
  10. We're going to also provide you with the figure of your respective budget which you can be in the near future from now. This is only possible with QuickBooks Enterprise Support Number

    ReplyDelete
  11. Perhaps you have trapped into a challenge with Intuit product and payroll services? You may be willing to know the best approach to get hold of the consumer support team by dialing QuickBooks Payroll Support USA. AccountWizy welcome you 24*7 to access the many support services of Intuit products asking for QuickBooks enhanced payroll support.

    ReplyDelete
  12. Being an ordinary business person, working on professional accounting software, like QuickBooks, is not always easy. Thus, users may have to face a number of issues and error messages while using the software; when you feel something went wrong with your accounting software and cannot find a way out, you can get technical support from QuickBooks Technical Support Phone Number, working day and night to solve any issues related to QuickBooks.

    ReplyDelete
  13. Enterprise support number provides you with proper assistance whenever you want it. You are able to avail Enterprise Support using E-mail yet QuickBooks Enterprise support number serves to be the ideal as a type of assistance. Here our experts will reply to your call and supply you perfect solutions on QuickBooks Enterprise Technical Support resolving all the issues faced by you.

    ReplyDelete

  14. There could be occasions as soon as you might face some type of delay in reaching QuickBooks Technical Support Number, let’s say in the period of filing taxes while there is lots of hush-hush then.

    ReplyDelete
  15. Dial QuickBooks Payroll tech support number to inquire of for QuickBooks enhanced payroll support to resolve payroll issues. We work for startups to small-scale, medium-sized to multinational companies. At AccountWizy, you can find well-qualified and trained accountants, Proadvisors who is able to handle such errors. QuickBooks Payroll Help Phone Number USA is a way of contacting us for Intuit product and QuickBooks Payroll subscription.

    ReplyDelete
  16. Of course, QuickBooks Support Number is certainly one among the list of awesome package in the company world. The accounting the main many companies varies based on this package. You will find so many fields it covers like creating invoices, managing taxes, managing payroll etc.

    ReplyDelete
  17. QuickBooks Customer Support Phone Number software makes you feel confident all the time by allowing you've got the ball always in your court. You can choose as per the norms of one's company the rules that suit you best.

    ReplyDelete
  18. You have got the best option option for connecting your field staff and your in-house staff in order to market closeness and harmony amongst both the groups.
    In addition QuickBooks Enterprise Support Phone Number enables you to work from anywhere at any point of that time period.

    ReplyDelete
  19. Some people are employing excel sheets for a few calculations. But, this sheet cannot calculate accurately the figures. This becomes one of several primary reasons for poor cashflow management in lot of businesses. It's going to be the time for Support For QuickBooks. The traders can’t earn money. But, we have been here to support a forecast.

    ReplyDelete

  20. However, being a typical or ordinary business person, focusing on acknowledged and professional accounting software, like QuickBooks Tech Support Number, is certainly not always easy.

    ReplyDelete
  21. a person can very quickly project the sales regarding the business. Our QuickBooks Support Phone Number team will really provide you know how to make a projection towards the business concerning the sales it has manufactured in a period period.

    ReplyDelete
  22. The group deployed at the final outcome of QuickBooks Technical Support Number takes great proper care of all from the issues for the software. QuickBooks Support telephone number have a team of experts which can be pro in handling all of the issues because of this incredible software. You may need not to worry all things considered as you are seeking help underneath the guidance of supremely talented and skilled support engineers that leave no stone unturned to land you of all of the errors which are part and parcel of QuickBooks.

    ReplyDelete
  23. If you’re encountering any type of QuickBooks’ related problem, you could get all that problems solved just by with the QuickBooks Support Number. QuickBooks users are often present in situations where they need to face many of the performance plus some other errors as a result of various causes in their computer system.

    ReplyDelete
  24. There are lots of payroll options made available due to the online kind of QuickBooks varying upon the necessity of accounting professionals and subscription plans. QuickBooks Technical Support Phone Number as well provides all possible assist with the users to make use of it optimally. An individual who keeps experience of experts has the ability to realize in regards to the latest updates.

    ReplyDelete
  25. In addition to this, you are able to keep access, control & client permissions associated with your organization requirement.Additionally, to avail data protection and recovery services, just dial QuickBooks Enterprise Help Phone Number.

    ReplyDelete
  26. The net is stuffed with faux numbers WHO decision themselves the QuickBooks Tech Support Number Provider. you’ll value more highly to dial their variety however that might be terribly risky. you’ll lose your QuickBooks Company file or the code itself. dig recommends dialing solely the authentic QuickBooks Support contact number.

    ReplyDelete
  27. QuickBooks payroll on the net is the absolute most desired software when it comes to dealing with one’s finances and managing it. This software has equipped almost all the QuickBooks Payroll Support Number user with a great deal strength which they feel accomplished.

    ReplyDelete
  28. The key intent behind QuickBooks Support number is to supply the technical help 24*7 so as with order to avoid wasting your productivity hours. This can be completely a toll-free QuickBooks Tech Support Phone Number client Service variety that you won’t pay any call charges. Of course, QuickBooks is the one the large choice of awesome package in the company world.

    ReplyDelete
  29. QuickBooks Tech Support Number is almost always safer to concentrate on updated version as it helps you incorporate all the latest features in your software and assists you undergo your task uninterrupted. You will discover simple steps that you need to follow.

    ReplyDelete
  30. Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
    If you are looking for any Big data Hadoop Related information please visit our website Big Data Hadoop Training In Bangalore page!

    ReplyDelete
  31. Hi Friend, what an outstanding Post. I liked the writing style and the way, you have presented the post. The points have helped to grab more information. QuickBooks Point of Sale is accounting software that helps in managing time and easily completes your tedious accounting task. In case of any problem, contact QuickBooks Customer Service Number +1 833-441-8848 and avail outstanding help from the experts.

    ReplyDelete
  32. This post is amazing and wonderful. Thank you for sharing such creativity. Are you looking for an ideal accounting software to manage your entire accounting and financial tasks. Then, there is no substitute for the QuickBooks Accounting Software. However, this software like others too is not immune to errors and bugs, thus if you come across one any time, make an immediate call to QuickBooks Support Phone Number +1-844-200-2627 and avail the right solutions instantly.

    ReplyDelete
  33. Hello! All my concerns about the subject have been answered by your post. Hope you will continue to write such a compelling blog. Try using QuickBooks accounting software if you have difficulty in managing your accounts. It has different features that make the accounting hazel-free. Contact QuickBooks Technical Support Phone Number 1-855-907-0605 and get your issues fixed. Or contact at QuickBooks Payroll Support Phone Number. read more: https://dentalphonenumber.com/quickbooks-payroll-support-phone-number/

    ReplyDelete
  34. Hey! Amazing content. I love your blog. Recently I have started using QuickBooks software for my business. I love the ease and different tools provided by this software. I highly recommend others to use QuickBooks software for their business. You can get instant help and support at QuickBooks Support Phone Number Florida 1-833-401-0204. Read more: https://tinyurl.com/vz56e5v OR visit: https://www.qb-dataservices.com/quickbooks-in-florida/

    ReplyDelete
  35. Hey! Outstanding post. Keep writing such appealing blogs. With QuickBooks, you can easily manage all your accounting process in one place. In case you find any inconvenience in QuickBooks software, then reach our experts via QuickBooks ProAdvisor Support Phone Number 1-833-401-0204. These experts are available 24/7 around the clock for you. Read more: https://tinyurl.com/vskk254 or visit us: https://www.mildaccounting.com/quickbooks-proadvisor-support-phone-number/

    ReplyDelete
  36. It holds information, cause, as well as the action causing the error. Banking error 9999 may encounter the user while searching online. It hangs, responds slower or even stops working. When trying updating the information, the users get entangled in error. If you would like to learn How To Troubleshoot QuickBooks Error 9999, you can continue reading this blog.

    ReplyDelete
  37. Facing any sort of discrepancy? You can't able to catch what happened to your software. Our QuickBooks Support Phone Number 1-833-780-0086 is always there to help you out in resolving the QuickBooks issue. Gain eminent aid regarding software installation to further instruction & fixing error issues. For More Visit: https://g.page/quickbooks-support-california

    ReplyDelete
  38. Oh wow helpful data..
    Thanks for sharing with us,
    We are again come on your website,
    Thanks and good day,
    If you need any logo then,
    Please visit our site,
    buylogo

    ReplyDelete
  39. Well explained and knowledgeable blog click here for QuickBooks support number for more detail dial on our QuickBooks Support phone number 844-908-0801

    ReplyDelete