Adding GMSPanoramaView in subview or resizing it - ios

I am using google panorama street view in ios, But i am not able to put GMSPanoramaView in subview , it occupies whole screen .Please help me regarding this.Or is there any way that we can put it view with desired size so that it should not occupy whole screen.
Right now I am using following code : and I am getting black screen while using this code.
#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
#interface NextViewController : UIViewController{
GMSPanoramaView *panoView_;
}
#property (weak, nonatomic) IBOutlet UIView *sub_View;
#end
-(void)loadView{
panoView_ = [[GMSPanoramaView alloc] initWithFrame:CGRectZero];
self.sub_View = panoView_;
[panoView_ moveNearCoordinate:CLLocationCoordinate2DMake(-33.732, 150.312)];
}

Related

MKMapview as an overlay

Is it possible to have an MKMapView lined up on top of another MKMapView with the top having a level of transparency so you can see the bottom. Further when the user swipes, I would like BOTH the top and bottom map to scroll, or zoom in unison.
I am finding the standard map too plain and the satellite map too intense and was hoping to combine them for effect.
Any thoughts?
You can do this, no problem at all. As you already described, just put a MKMapView in your window and a second one on top. Let's assume we call them _map1 and _map2, the latter being on top of _map1. The MKMapViewDelegate protocol will let you know when a user scrolls/moves/zooms _map2, so you can tell _map1 to display the same visible region of _map2.
In my example I use a slider to set the level of transparency of _map2.
#import "ViewController.h"
#import MapKit;
#interface ViewController () <MKMapViewDelegate>
#property (weak, nonatomic) IBOutlet MKMapView *map1;
#property (weak, nonatomic) IBOutlet MKMapView *map2;
#property (weak, nonatomic) IBOutlet UISlider *alphaSlider;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[_map1 setMapType:MKMapTypeSatellite];
[_map2 setMapType:MKMapTypeStandard];
[_map2 setAlpha:0.5];
[_map2 setDelegate:self];
[_alphaSlider addTarget:self action:#selector(sliderChanged) forControlEvents:UIControlEventAllEvents] ;
_alphaSlider.value = _map2.alpha;
}
- (void)mapViewDidChangeVisibleRegion:(MKMapView *)mapView
{
// _map2 is on top and will receive visible region updates, i.e. the user scrolled/moved/zoomed the map
// just pass the new region to _map1 so it will be similar to that one of _map2
[_map1 setRegion:_map2.region];
}
- (void)sliderChanged
{
[_map2 setAlpha:_alphaSlider.value];
}

When adding a UITableView to an existing ViewController with a JTCalendar view up top, the table covers the entire view

I'm currently using the JTCalendar calendar control to show a calendar grid on the top half of my view controller. Before I attempt to add a table, the calendar view takes up the top half, and the bottom half is empty.
After I add the code for the UITableView, which I want to be displayed in the bottom half, the table is now taking up the entire view, rather than just fitting into the bottom half. I've set up the table view like so:
ViewController.h:
#import <UIKit/UIKit.h>
#import "JTCalendar.h"
#interface ViewController : UIViewController<JTCalendarDataSource, UITableViewDataSource,UITableViewDelegate>
#property (weak, nonatomic) IBOutlet JTCalendarMenuView *calendarMenuView;
#property (weak, nonatomic) IBOutlet JTCalendarContentView *calendarContentView;
#property (weak, nonatomic) IBOutlet NSLayoutConstraint *calendarContentViewHeight;
#property (strong, nonatomic) JTCalendar *calendar;
#property (strong, nonatomic) NSArray *agendaTableArray;
#end
ViewController.m:
- (void)viewDidLoad
{
[super viewDidLoad];
self.calendar = [JTCalendar new];
// All modifications on calendarAppearance have to be done before setMenuMonthsView and setContentView
// Or you will have to call reloadAppearance
{
self.calendar.calendarAppearance.calendar.firstWeekday = 1;
self.calendar.calendarAppearance.dayCircleRatio = 9. / 10.;
self.calendar.calendarAppearance.ratioContentMenu = 1.;
}
////
// Initialize Day Agenda table
UITableView *agendaTable = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
agendaTable.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
agendaTable.delegate = self;
agendaTable.dataSource = self;
[agendaTable reloadData];
[self.view addSubview: agendaTable];
/////
[self.calendar setMenuMonthsView:self.calendarMenuView];
[self.calendar setContentView:self.calendarContentView];
[self.calendar setDataSource:self];
}
What's causing it to take up the entire view? I made sure to have it be a subview, but that doesn't seem to be working. Did I set up the table incorrectly in any way?
You're initializing the tableview with a fullscreen frame, and haven't told it to shrink down to the height you want. Try applying a fixed height constraint with the height you want, then add constraints to the left, right, and bottom sides of the tableview.
Apple has lots of documentation on how to add constraints programmatically: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/AutoLayoutinCode/AutoLayoutinCode.html
Or you can move all this stuff into the interface builder and change sizes/constraints that way.

Button moves when zooming image. Objective-c

Could anyone please help me. When I zoom an image button changes its position. Do not know how to heal it.. I assume that might be because they are under "ScrollView" but when I add buttons to "View" they don't respond, they only respond in "ScrollView".
*.h
#interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIScrollViewDelegate> {
UIImageView *imageView;
UIButton *addImageBtn;
}
#property (nonatomic, retain) IBOutlet UIButton *addImageBtn;
*.m
#synthesize addImageBtn;
Thanks in advance!
Do you really need the buttons inside the scroll? Is autolayout on ? Attach the buttons to the bottom of the container view and put it outside the scroll

merge iAD within another view / definition

i am having trouble merging iAD into my current code/definition. i already have code set for a card scroll view style display and wanted to add iAD to the same view controller:
how can i do that without getting the errors i am getting?
this is the code for card scroll view in view controller.h
#interface ViewController1 : UIViewController <CardScrollViewDelegate>
#end
this is my code for iAD for view controller.h but should be merged with the above otherwise i get another error saying duplicate definition:
#interface ViewController1 : UIViewController <ADBannerViewDelegate> {
SLComposeViewController *mySLComposeSheet;
}
#property (weak, nonatomic) IBOutlet ADBannerView *banner1;
The view controller name / custom class im trying to add them both to is ViewController1
UPDATE:
its much simpler than i thought, just add a comma (FOR THOSE WHO ARE CURIOUS LIKE I WAS)
#interface ViewController1 : UIViewController <CardScrollViewDelegate, ADBannerViewDelegate> {
}
#property (weak, nonatomic) IBOutlet ADBannerView *banner1;
#end
Your code and/or question is ambiguious. I see 3 view controllers and 2 delegates. Eitherway...which viewcontroller are you trying to add it to? Whichever one it is. Inside the implementation file should be the following:
Remember to import iAd and your code should look like this:
#import <iAd/iAd.h>;
#interface ViewController1 : UIViewController <ADBannerViewDelegate>
{
ADBannerView *banner1;
BOOL bannerIsVisible;
}
#property (nonatomic,assign) BOOL bannerIsVisible;
Then, in viewDidLoad you can load it in a frame etc...

How can I manipulate objects in a subView?

Got away from XCode programming for a while, now I'm starting back and feel like I'm starting ALL over. I have a simple example that's driving me crazy.
I have created a sub class of UIView called Word1View and added it to my storyboard.
I declared it as a property in the main view controller and attached it as an IBOutlet to the main view. I can draw on this view using Core Graphics with no problems (rectangles, lines, etc). Here's the code in the ".h" file. The property is synthesized correctly in the ".m"
#import <UIKit/UIKit.h>
#import "Word1View.h"
#interface Board3ViewController : UIViewController
{
Word1View *word1View;
}
#property (nonatomic, strong) IBOutlet Word1View *word1View;
#end
Now, here's the problem. I have added a UILabel (I will be adding UIImageFiles later)
in Word1View.h it appears as so:
#import <UIKit/UIKit.h>
#interface Word1View : UIView
{
UILabel *testLabel;
}
#property (nonatomic, retain) UILabel *testLabel;
#end
This property is also synthesized correctly. The UILabel was added to the view in the main storyboard. I tried to make this an IBOutlet, but could not hook it up as long as it was part of the subview. I tried to access the UILabel in my main view controller as so:
[super viewDidLoad];
[self.view addSubview:word1View];
NSLog(#"Label text is: %#", word1View.testLabel.text);
I don't have any access to that label as evidenced by the output to NSLog which is:
Board3[14520:c07] Label text is: (null)
I would like to be able to access the label (change its text, properties etc) from my main View Controller.
Any help is greatly appreciated. Thank you.
You need to instantiate your UILabel and give it some text.
wordView1 = [[UILabel alloc] init];
wordView.text = #"Some Text";

Resources