How to `presentViewController` with custom animation on iOS 6? - ios6

How can I have custom animation for view controller presented with presentViewController method on iOS 6+ ? I want the new VC's view to zoom in from some point.
I'm using the following routine to fade in new controller:
CATransition* transition = [CATransition animation];
transition.duration = 1;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromBottom;
[self.view.window.layer addAnimation:transition forKey:kCATransition];
[self presentViewController:viewController animated:NO completion:nil];
But I'm not sure how and whether it's possible to zoom in view this way.

Related

How do you stop scrolling to top when grid store is reloaded - take 2

I have an app that uses ExtJS 3.3.0. It uses an EditorGridPanel in which after the store is reloaded - I would like it to preserve the scroll position of the grid rather than sending it back up to the top.
Since it's an earlier version of ExtJS - this does not work.
viewConfig: {
preserveScrollOnRefresh: true
}
I thought I had found a solution per Zeke's suggestion to use a scrollTo function like so:
//Save position
var top = grid.getView().scrollergetScroll().top;
//Restore position
grid.getView().scroller.scrollTo('top',top);
This works great - except that after it's done reloading it goes right back up to the top. Basically this would be a perfect solution if only I didn't need preserve the cursor position after reloading the store.
grid().getStore().reload({
callback: function (response) {
//Works at this point
grid.getView().scroller.scrollTo('top',top);
}
}
//However the cursor pops right back up to the top after popping out of
//reload() block
Thanks in advance
This is a little kludgy - maybe the best strategy is just not to use older versions of ExtJS - but this seems to work okay.
Basically just declare some global variables that can be seen from anywhere in the file - one is a flag to indicate that the event that triggers the reload has occured (rowClicked), and one to represent the last known position of the scrollbar
var rowClicked = false;
var prevScrollPosition = -1;
When the event occurs that will trigger the re-load - set the global variable rowClicked to true
rowclick: function(grid, rowIndex, event) {
rowClicked = true;
Then in the listeners of the grid use the rowClicked variable to determine when to re-position the scrollbar.
listeners : {
bodyscroll: function(sl, st) {
if (rowClicked) {
getScenarioLineOrderNumbersGrid().getView().scroller.scrollTo('top',prevScrollPosition);
rowClicked = false;
}
prevScrollPosition = st;
}
Kludgy - but it works.

How to add the point event listener into anychart.stock() on AnyChart?

In Anystock/AnyChart, I want to listen to the point event when the mouse clicks.
So, I added the following code as a script.
anychart.onDocumentReady(function () {
// create data table
var table = anychart.data.table();
// add data
table.addData([
['2015-12-24', 511.53, 514.98, 505.79, 506.40],
['2015-12-25', 512.53, 514.88, 505.69, 510.34],
['2015-12-26', 511.83, 514.98, 505.59, 507.23],
['2015-12-27', 511.22, 515.30, 505.49, 506.47],
['2015-12-28', 511.53, 514.98, 505.79, 506.40],
['2015-12-29', 512.53, 513.88, 505.69, 510.34],
['2015-12-30', 511.83, 512.98, 502.59, 503.23],
['2015-12-31', 511.22, 515.30, 505.49, 506.47],
['2016-01-01', 510.35, 515.72, 505.23, 508.80]
]);
// map loaded data
var mapping = table.mapAs({'open': 1, 'high': 2, 'low': 3, 'close': 4});
// create a stock chart
var chart = anychart.stock();
// add a series using mapping
chart.plot(0).ohlc(mapping).name('ACME Corp. Stock Prices');
// set container id for the chart
chart.container('container');
// initiate chart drawing
chart.draw();
// add a mount event listener - It is fine.
chart.listen('click', function(e){
alert(e);
});
// add a point event listener - It does not work.
chart.listen('pointClick', function(e){
alert(e);
});
});
The mouse event was being raised successfully, but the point event did not work.
How does we add the point event listener into anychart.stock() on AnyChart?
If anyone has a solution already, it would be great if you could share it.
Unfortunately, the current version of AnyStock (8.3.0) doesn't support point related events as basic charts. If you want to show additional information about the point you can show it in the point tooltip using formatter function - https://api.anychart.com/anychart.core.ui.Tooltip#format

How to switch from one view controller to another in a chain

I have a initial view controller, from which i need to push to first view controller. on back click of first view controller instead of going back to initial view controller i need to go to a third view controller. from back click on third view controller it should go back to initial view controller. Could anyone suggest me how to do it in ios6 and also in ios7.
Call setViewControllers:animated: after the push, to insert the middle view controller into the stack.
there are many other way to do but i prefer this one:
for that you have to add programmatically navigation bar button as "back" at first view controller(in your case) but in this case you required back_arrow image:
UIImage *faceImage = [UIImage imageNamed:#"back_arrow.png"];
UIButton *face = [UIButton buttonWithType:UIButtonTypeCustom];
face.bounds = CGRectMake( 10, 0, faceImage.size.width, faceImage.size.height );
[face addTarget:self action:#selector(handleBack) forControlEvents:UIControlEventTouchUpInside];
[face setImage:faceImage forState:UIControlStateNormal];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:face];
self.navigationItem.leftBarButtonItem = backButton;
[self.navigationItem setHidesBackButton:YES animated:YES];
[self.navigationItem setLeftBarButtonItem:nil animated:NO];
[self.navigationItem setBackBarButtonItem:nil];
-(void)handleBack
{
//got third view controller here
}
may it will help you.

How can I present a ModalViewController from a UIActivity item picked from UIActivity View Controller?

I am working on an app that presents some data in a detailViewController. I have a rightBarButton in the navbar that presents a UIActivityViewController that is filled with my own UIActivity sublclassed items. Most of them work fine as they are just changing a small aspect to the data from the detail view, but I need one of them to open a modalViewController when selected. I keep getting the following warning from the console.....
Warning: Attempt to present <UINavigationController: 0x1fd00590>
on <UITabBarController: 0x1fde1070> which is already presenting <MPActivityViewController: 0x1fd2f970>
I suppose it is worth noting that the app doesn't crash but the modal view doesn't appear either. I am assuming that the UIActivityViewController is a modal view itself and you can only display one of those at a time so the task is to figure out how to perform my segue after the ActivityView has disappeared, but thats where I am stumped. I welcome any help, thoughts or feedback. I've tried google but haven't had much luck, I assume because The UIActivityViewController is so new.
Here is my setup so far,
my UIActivity objects have a delegate set to the detailViewController for a custom protocol that lets the detailViewController perform the data changes and then update its view.
for the activities in question that should present the modalView controller I have tried a few approaches that all get the same warning.
None of These Works!!!
1) simply tried performing segue from my delegate method
- (void) activityDidRequestTransactionEdit
{
NSLog(#"activityDidRequestTransactionEdit");
[self performSegueWithIdentifier:#"editTransaction" sender:self];
}
2)tried setting a completion block on the UIActivityViewController and having my delegate method set a bool flag that the modal view should be shown(self.editor)
[activityViewController setCompletionHandler:^(NSString *activityType, BOOL completed) {
NSLog(#"completed dialog - activity: %# - finished flag: %d", activityType, completed);
if (completed && self.editor) {
[self performSegueWithIdentifier:#"editTransaction" sender:self];
}
}];
3) subclassing the UIActivityViewController itself, giving it the detailView as a delegate, and overriding it's dismissViewControllerAnimated: method with my own completion block
- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
[super dismissViewControllerAnimated:flag completion:^{
[self.MPActivityDelegate activityDidRequestTransactionEdit];
}];
}
The working Solution
In the UIActivity subclass you need to override this method like so
- (UIViewController *) activityViewController {
MPEditMyDataViewController *controller = [[MPEditMyDataViewController alloc] init];
controller.activity = self; // more on this property below
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
return navController;
}
in your MPEditMyDataViewController.h (the view controller the chosen action should produce)
You need a property back to the activity subclass like so
#property (strong, nonatomic) MPEditMyDataActivity *activity;
in your MPEditMyDataViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:#selector(cancel)];
self.navigationItem.leftBarButtonItem = cancelButton;
}
// here's how you dismiss the view controller when you are done with it
// after saving the changes to your data or whatever the view controller is supposed to do.
-(void) cancel
{
NSLog(#"Cancel Button Pushed");
[self.activity activityDidFinish:YES];
}
#end
Did some more documentation digging and found this method for UIActivity subclassing
- (UIViewController *) activityViewController
it gets my view controller to pop up like I wanted by returning it from here instead of trying to segue it from my detailViewController. Now to figure out how to dismiss it when I'm done with it!!!!

From Portrait mode to Landscape mode in iOS5, iOS6

I want to turn only one of my views within my app to landscape right.
All my other views are in portrait mode. Previous view is in portrait mode. I pushed landscape view to portrait view. How can I do it correctly?
in my landscape view controller:
//Orientation
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
// New Autorotation support
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeRight;
}
You can use this in you view controller
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
this will make sure the orientation is landscape right.
For changing the orientation in a device you can do sum thng like this..
-(void)viewDidLoad
{
orientation = [[UIDevice currentDevice] orientation];
if(intOrientation == UIInterfaceOrientationLandscapeRight)
orientation = UIDeviceOrientationLandscapeRight;
}
Hope it helps you
I've solved. Thanks Sang. I used this example:
Also see this
Or this

Resources