I have few help tips which are custom subviews which I want to show both in portrait and landscape mode when the app is launched for the first time. Next time the app is launched they don't show up. I want to do this in viewDidAppear method. I wrote the code but not able to figure out how to implement it in landscape mode.
Here's the code for portrait mode in viewDidAppear method:
for index in subviews{
index.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("showPopover:")))
if index == self.hotSpotOne && HelpTipRegistry.shouldShowTip(HelpTipRegistry.names.HomeScreenSearch){
index.constraintList.append(NSLayoutConstraint(item: index, attribute: NSLayoutAttribute.Leading, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Leading, multiplier: 1.0, constant: -1))
index.constraintList.append(NSLayoutConstraint(item: index
, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Top, multiplier: 1.0, constant: 16))
index.helptip(index, parentView: self.view, delay: 0.0)
}
else if index == self.hotSpotTwo && HelpTipRegistry.shouldShowTip(HelpTipRegistry.names.HomeScreenEvent){
index.constraintList.append(NSLayoutConstraint(item: index, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterX, multiplier: 1.0, constant: 0))
index.constraintList.append(NSLayoutConstraint(item: index
, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Top, multiplier: 1.0, constant: 150))
index.helptip(index, parentView: self.view, delay: 0.3)
}
else if HelpTipRegistry.shouldShowTip(HelpTipRegistry.names.HomeScreenProduct){
index.constraintList.append(NSLayoutConstraint(item: index, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterX, multiplier: 1.0, constant: 0))
index.constraintList.append(NSLayoutConstraint(item: index
, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: -2))
index.helptip(index, parentView: self.view, delay: 0.6)
}
}
In landscape mode only one subview should be visible instead of 3. I don't know how to implement landscape mode code in viewDidAppear method.
Any help is appreciated! Thanks!