core-plot adding UITable - uitableview

i am still very new to objective c and in fact this is my first attempt to build an app so please bear with me...
I am trying to add an UITable beside core-plot graph, i have taken CPTestApp example and stated to work off that, i was able to get the graph part working ok but i am having trouble with UITable. Below is the screenshot of how it look at the moment.UITable is upside down and the text is all mirrored..
below is rotation part, can someone point me with an example for UITable rotation together with graph...UITable is populated with an array of values and that is working ok too..
i probably need some guidance to figure out the correct way to add UItable to the coreplothosting view layer
Thanks
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if (UIInterfaceOrientationIsLandscape(fromInterfaceOrientation))
{
// Move the plots into place for portrait
scatterPlotView.frame = CGRectMake(20.0f, 55.0f, 728.0f, 556.0f);
tblSimpleTable.frame = CGRectMake(20.0f, 644.0f, 728.0f, 340.0f);
[tblSimpleTable reloadData];
}
else
{
// Move the plots into place for landscape
scatterPlotView.frame = CGRectMake(20.0f, 55.0f, 858.0f, 677.0f);
tblSimpleTable.frame = CGRectMake(878.0f, 51.0f, 220.0f, 677.0f);
[tblSimpleTable reloadData];
}
}

Core Plot applies a flip transform to all of its Core Animation layers so that the drawing code can be shared between iOS and MacOS. This is what you're seeing.
Make sure your UITable and graph hosting view are siblings (i.e., have a common parent view) and one is not a subview of the other.

Related

Key-Frame Animation appears fuzzy when moving Frames?

I use JazzHands to create a key frame based animation in a UIScrollView.
Here is an example. Look at the view at the top. When you move from page to page. While the animation is running the view at the top is slightly moving from left to right. The animation appears a bit fuzzy.
Here is the code taken from the example here:
IFTTTFrameAnimation *titleView1FrameAnimation = [IFTTTFrameAnimation new];
titleView1FrameAnimation.view = self.titleView1;
[self.animator addAnimation:titleView1FrameAnimation];
[titleView1FrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(1)
andFrame:self.titleView1.frame]];
[titleView1FrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(2)
andFrame:CGRectOffset(self.titleView1.frame, timeForPage(2), 0)]];
[titleView1FrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(3)
andFrame:CGRectOffset(self.titleView1.frame, timeForPage(3), 0)]];
[titleView1FrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(4)
andFrame:CGRectOffset(self.titleView1.frame, timeForPage(4), 0)]];
When running the demo take a look at the part marked with red in the following screenshot:
Edit: Here is the code containing this problem: https://github.com/steffimueller/Intro-Guide-View-for-Talk.ai
How can I make the animation running smooth and less fuzzy?
This is due to the frame rate in the JazzHands IFTTTAnimatedScrollViewController being set for non-retina displays. You need to double the number in timeForPage, and also use double the number of the contentOffset in animate, but use the original non-doubled values of timeForPage in places where you were using that for laying out the positions of views instead of using it for the animation time.
Here's a Gist of the changes you'd have to make to your example to get it working. Fixed Demo Gist
You need this method for setting the animation times:
#define timeForPage(page) (NSInteger)(self.view.frame.size.width * (page - 1) * 2.0)
And this one for setting the centers of your views based on the page dimensions:
#define centerForPage(page) (NSInteger)(self.view.frame.size.width * (page - 1))
Then you need to override the scrollViewDidScroll: method in IFTTTAnimatedScrollViewController to use double the numbers it's currently using.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self.animator animate:(NSInteger)(scrollView.contentOffset.x * 2)];
}
We'll work on getting the JazzHands demo updated!
Before you start your animation call:
view.layer.shouldRasterize = YES; (seems that you are using objective-c so I put YES here, for swift should be true)
As soon as the animation is finished call
view.layer.shouldRasterize = NO; (seems that you are using objective-c so I put NO here, for swift should be false)
You should always use it when you animating a view
You can see more details about it in the WWDC 2012 Polishing Your Interface Rotations video (paid developer subscription needed)
I hope that helps you!
[EDIT]
Every Time you call the method animate set shouldRasterize to YES before it, like in the example bellow:
titleView1FrameAnimation.view.layer.shouldRasterize = YES;
[self. titleView1FrameAnimation animate:scrollView.contentOffset.x];
I've messed around a bit with the code and it seems that keeping those top views in place while the scrollview is scrolling made it jiggle left and right.
What I did is take out the title view from the scroll view and add it to the view controller view.
You can see it in action here
Later edit:
To actually see what I've changed you can check the file differences in Git. Basically I moved your titleViews (titleView1, titleView2, etc) from the scrollView to the view controller's view (so basically I've replaced all the lines that were like this:
[self.scrollView addSubView:self.titleView1]
to something like this:
[self.view addSubView:self.titleView1]
After that I've also took out the keyframe animations that were keeping your title views in place since they were not moving with the scrollview anymore. Practically I've deleted all the lines that were adding a frame animation to your titleviews from each configurePageXAnimation.
2nd question answer:
Say your screenshot view is called screenshotView. You can go ahead and create it like this:
UIImageView *screenshotView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"ScreenshotImage"]];
[self.view addSubview:screenshotView];
self.screenshotView = screenshotView;
[self.screenshotView setCenter:CGPointMake(self.view.center.x + self.view.bounds.size.width, <#yourDesiredY#>)];
And animate it like this:
//screenshotView frame animation
IFTTTFrameAnimation *screenshotViewFrameAnimation = [IFTTTFrameAnimation new];
screenshotViewFrameAnimation.view = self.screenshotView;
[self.animator screenshotViewFrameAnimation];
[screenshotViewFrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(1) andFrame:self.screenshotView.frame]];
[screenshotViewFrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(2) andFrame:CGRectOffset(self.screenshotView.frame, -self.scrollView.bounds.size.width, 0.0)]];
[screenshotViewFrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(3) andFrame:CGRectOffset(self.screenshotView.frame, -self.scrollView.bounds.size.width, 0.0)]];
[screenshotViewFrameAnimation addKeyFrame:[[IFTTTAnimationKeyFrame alloc] initWithTime:timeForPage(4) andFrame:CGRectOffset(self.screenshotView.frame, -self.scrollView.bounds.size.width * 2, 0.0)]];

Cropping/zooming not working while setting iOS Wallpaper using PhotoLibrary private framework

I have managed (with the help of this post) to open up a PLStaticWallpaperImageViewController from the PhotoLibrary private framework, which allows the direct setting of the wallpaper and lock screen (using same UI as the Photos app). Unfortunately, the image cropping/zooming features don't seem to work, as touches to the image view itself don't seem to be coming through (the main view is also not dismissed properly after the cancel/set buttons are touched, but this isn't so important).
I have an Xcode project demonstrating the wallpaper setting (can be run in simulator as well as a non-jailbroken device):
https://github.com/newenglander/WallpaperTest/
The code is quite basic, and involves a ViewController inheriting from PLStaticWallpaperImageViewController and implementing an init method similar to the following:
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [self initWithUIImage:[UIImage imageWithContentsOfFile:#"/System/Library/WidgetResources /ibutton/white_i#2x.png"]];
self.allowsEditing = YES;
self.saveWallpaperData = YES;
return self;
}
(It will be necessary to allow access to the photo library after the first launch, and for some reason the popup for this comes up behind the app, rather than on top.)
Perhaps someone has insight as to why the cropping/zooming isn't working, or can give me an alternative way to set the wallpaper in an app (destined for Cydia rather than the App Store of course)?
Use this sample project, working very well.
Have inside camera control and custom layout, crop image when taken or after chose from your library, i used for my project and in very simple to customize.
https://github.com/yuvirajsinh/YCameraView
//---------- Answer improved----------//
I take a look on your project and i see 2 problem:
here you have 3 warning of semantic issue:
- (id)initWithUIImage:(id)arg1 cropRect:(struct CGRect { struct CGPoint { float x_1_1_1; float x_1_1_2; } x1; struct CGSize { float x_2_1_1; float x_2_1_2; } x2; })arg2;
in your ViewController.m you setting to get the image from where?
- (id)initWithCoder:(NSCoder *)aDecoder
{
// black_i
//what directory is this?
self = [self initWithUIImage:[UIImage imageWithContentsOfFile:#"/System/Library/WidgetResources/ibutton/white_i#2x.png"]];
//--------------------
self.allowsEditing = YES;
self.saveWallpaperData = YES;
return self;
}
i try to remove your
- (id)initWithUIImage:(id)arg1 cropRect:(struct CGRect { struct CGPoint { float x_1_1_1; float x_1_1_2; } x1; struct CGSize { float x_2_1_1; float x_2_1_2; } x2; })arg2;
change IMG directory in to:
self = [self initWithUIImage:[UIImage imageNamed:#"myImage.png"]];
and all working well but can't crop image, with my git hub YCameraView you have first understand how it work CROPPING function if you want to use crop or more simple, you have to create a fullScreen UICameraPicker allow user to get from camera or from library and allow the editing in cameraPicker then you can load a new picture in your View like this
self = [self initWithUIImage:[UIImage imageNamed:imageSelected.image]];
for a dismiss view, you can't because is a full app allow user to setUp background wallpaper and you can't terminate the app to see a SpringBoard, you have to create first view > picker > detail view with settings for a Home and LockScreen > then dismiss and come back to a first view.
PS: I think in your project to enable editing direct in a view you have to improve your code with a pinch and pan gesture on the UIView
Hope this help you!

Table View in Popover Won't Scroll When Over AGSMapView

I'm using the ArcGIS Runtime SDK for iOS, and I have a subclass of UITableViewController that I'm presenting in a popover; the base view of the main view controller being displayed is an AGSMapView with an AGSGraphicsLayer (AGSSimpleRenderer attached). When the popover is presented, there is no ability to select a cell, and scrolling is extremely limited. When I change the base view controller's view from an AGSMapView to a blank UIView, the table view in the popover works perfectly.
My viewDidLoad: is as follows:
[super viewDidLoad];
self.mapView.layerDelegate = self;
self.mapView.calloutDelegate = self;
self.mapView.callout.delegate = self;
// Create an instance of a tiled map service layer.
AGSTiledMapServiceLayer *tiledLayer = [[AGSTiledMapServiceLayer alloc] initWithURL:[NSURL URLWithString:#"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"]];
// Add it to the map view.
[self.mapView addMapLayer:tiledLayer withName:#"Tiled Layer"];
AGSSimpleMarkerSymbol *simpleMarkerSymbol = [AGSSimpleMarkerSymbol simpleMarkerSymbol];
self.graphicsLayer.renderer = [AGSSimpleRenderer simpleRendererWithSymbol:simpleMarkerSymbol];
// Add graphics layer to the map view.
[self.mapView addMapLayer:self.graphicsLayer withName:#"Graphics Layer"];
Could this be a bug in the AGSMapView implementation, and if so, how do I go about reporting it?
Thanks in advance.
Related: Sister Question in the Esri Forums
EDIT
I determined that the issue is fairly difficult to reproduce, so I added mapViewDidLoad: to add current location. This causes the issue to occur without fail. My code is as follows:
- (void)mapViewDidLoad:(AGSMapView *)mapView {
[self.mapView.locationDisplay startDataSource];
self.mapView.locationDisplay.autoPanMode = AGSLocationDisplayAutoPanModeDefault;
}
A simple workaround is to make the main view of your view controller a UIView and then add both the AGSMapView and your popover as subviews of the base UIView.
This was revealed to be a bug in the ArcGIS Runtime SDK for iOS. Esri Support contacted me and told me that it will be fixed in the next release.
I had this problem but i solve this with adding graphic layer after TiledLayer loaded not in viewDidLoad
-(void)layerDidLoad:(AGSLayer *)layer
{
NSLog(#"layer %# loaded",layer.name);
if(!self.graphicLayer)
{
self.graphicLayer = [AGSGraphicsLayer graphicsLayer];
[self.mapView addMapLayer:self.graphicLayer withName:#"Graphic Layer"];
}
}

splitting view into three parts(not splitview)

i want to split the view into three different parts.each part i want to set different color.
i have tried using drawing methods in drawrect.i've succeded but the splitting should be done on button click.
here is the code that i have used.
-(void)drawRect:(CGRect)rect
{
int i=0;
float width =rect.size.width/[elements count];
CGRect paintRect;
for (NSString *color in self.elements)
{
paintRect = CGRectMake(rect.origin.x+(i*width), rect.origin.y, width, rect.size.height);
i++;
UIColor *colorr=[UIColor colorWithHexString:color];
[colorr set];
UIRectFill(paintRect);
}
}
enter code here
now i want to use this code on button click.....
help...thanx in advanced
a much easier way to do this would be to put three custom buttons or custom views and arrange them in code.
Put the backcolor of the button or view to the selections you want.
And in the case of button you attach the UIControlEventTouchUpInside event and trap the touch.
in the case of a view. you would subclass the view and override the touch events associated to that view and build your own "click" event
This is a lot less complicated than trying to create your own touch locations in a single view.
Another option would be to grab the color at the pixel that is touched. there are a lot of examples of this on stackoverflow. here is one
Hope that helps

MkMapView cancel loading google tiles

I have a case where I need to import an overlay map in top of MkMapView.
The overlay totally covers the google tiles below so there is no need loading, plus it adds overhead to the app.
Is there a way to tell mkMapView to stop loading tiles?
Actually there are 2 ways to implement the real "Hide Google tiles" method (johndope solution only puts an overlay on top of it but doesn't prevent the tiles from loading).
Beware that option one described below might get your application rejected while option 2 will not but is a bit more complex.
Common Part: Retrieve the MKMapTileView object
Inside each MKMapView lies an undocumented class of type: MKMapTileView. Retrieving it is NOT a reason for rejection. In this code the MKMapView instance will be called mapView
UIView* scrollview = [[[[mapView subviews] objectAtIndex:0] subviews] objectAtIndex:0];
UIView* mkTiles = [[scrollview subviews] objectAtIndex:0]; // <- MKMapTileView instance
Option 1: Undocumented Method (!! can be a reason for rejection !! )
if ( [mkTiles respondsToSelector:#selector(setDrawingEnabled:)])
[mkTiles performSelector:#selector(setDrawingEnabled:) withObject:(id)NO];
This will prevent the undocumented method setDrawingEnabled to be called on the MKMapTileView instance.
Option 2: Method Swizzling
Outside of your controller implementation you will write someting like:
// Import runtime.h to unleash the power of objective C
#import <objc/runtime.h>
// this will hold the old drawLayer:inContext: implementation
static void (*_origDrawLayerInContext)(id, SEL, CALayer*, CGContextRef);
// this will override the drawLayer:inContext: method
static void OverrideDrawLayerInContext(UIView *self, SEL _cmd, CALayer *layer, CGContextRef context)
{
// uncommenting this next line will still perform the old behavior
//_origDrawLayerInContext(self, _cmd, layer, context);
// change colors if needed so that you don't have a black background
layer.backgroundColor = RGB(35, 160, 211).CGColor;
CGContextSetRGBFillColor(context, 35/255.0f, 160/255.0f, 211/255.0f, 1.0f);
CGContextFillRect(context, layer.bounds);
}
And somewhere in your code (once your map view is loaded!) :
// Retrieve original method object
Method origMethod = class_getInstanceMethod([mkTiles class],
#selector(drawLayer:inContext:));
// from this method, retrieve its implementation (actual work done)
_origDrawLayerInContext = (void *)method_getImplementation(origMethod);
// override this method with the one you created
if(!class_addMethod([mkTiles class],
#selector(drawLayer:inContext:),
(IMP)OverrideDrawLayerInContext,
method_getTypeEncoding(origMethod)))
{
method_setImplementation(origMethod, (IMP)OverrideDrawLayerInContext);
}
Hope this helps anyone, this code was originally described in this blog post.
As far as I know you can't prevent MKMapView from loading Google Maps tiles, and there's a chance your app will be rejected if it covers up the Google logo while displaying an MKMapView – you may want to consider writing a custom UIScrollView to display your map instead.
I encountered a related problem but in my case my overlay didn't cover all the google tiles.
If anyone has this problem, and is trying to stop loading the google tiles, I managed to superimpose one gray tile(256x256) overlay over the google map tiles.
To do this, the top level tile must be
/FakeTiles/1/1/0.png and add this directory to resources to project.
(N.B. don't drag this into project > Add files > Folders > Create folder references for any folders)
//hack to overlay grey tiles
NSString *fakeTileDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:#"FakeTiles"];
TileOverlay *greyOverlay = [[TileOverlay alloc] initWithTileDirectory:fakeTileDirectory];
[mapView addOverlay:greyOverlay];
[greyOverlay release];
then add your custom tile overlay.
Then you need this code to scale the grey tile
Calculating tiles to display in a MapRect when "over-zoomed" beyond the overlay tile set

Resources