I somehow can't get a Scrollview to work vertically.
I created a simple ViewController with a Scrollview, that has equal width and height as Safe Area and filled it with one big label, which has also same width as safe area. But it doesn't scroll.
If I don't constrain the label, I get one long line which I can scroll horizontally. Why doesn't it work vertically?
<scene sceneID="PWe-2P-e7G">
<objects>
<viewController id="dVm-1J-JI9" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="AtX-Pv-6wj">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VNx-Wi-Vg6">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MqU-0Y-fM2">
<rect key="frame" x="-117" y="481" width="1000.5" height="61"/>
<mutableString key="text">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</mutableString>
<fontDescription key="fontDescription" type="system" pointSize="40"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="MqU-0Y-fM2" firstAttribute="top" secondItem="VNx-Wi-Vg6" secondAttribute="top" id="rFR-UU-4Jh"/>
</constraints>
</scrollView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="VNx-Wi-Vg6" firstAttribute="height" secondItem="cuD-5b-v6o" secondAttribute="height" id="5PV-lk-7KG"/>
<constraint firstItem="VNx-Wi-Vg6" firstAttribute="width" secondItem="cuD-5b-v6o" secondAttribute="width" id="ZBA-5x-Gzn"/>
<constraint firstItem="MqU-0Y-fM2" firstAttribute="width" secondItem="cuD-5b-v6o" secondAttribute="width" id="v3U-b4-7cx"/>
</constraints>
<viewLayoutGuide key="safeArea" id="cuD-5b-v6o"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rsr-pH-xUO" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="15.625" y="707.8125"/>
</scene>
Your scroll view is able to scroll horizontally because the horizontal content size of the label is more than the width of the scroll view horizontally.
I think your code is working perfectly fine.. To see your label working, add lots of new line characters in the label. Something like i \n am \n and so on.
After the label has increased its size vertically more than the scroll view size.. it should start scrolling.
I'm using dependency injection to launch Wikitude from my PCL project.
I'm using the WikitudeSDKSample. I've integrated it and it compiles.
When I run it, it shows a blank white page with the VC name at the top. It never initializes the camera or the AR. No errors.
Here's what I got so far:
[assembly: Xamarin.Forms.Dependency(typeof(AugmentedRealityImplementation))]
namespace UXDivers.Artina.Grial
{
public class AugmentedRealityImplementation : IAugmentedReality
{
public AugmentedRealityImplementation() { }
public void LaunchWikitude()
{
var storyboard = UIStoryboard.FromName("MainStoryboard_iPhone", null);
var controller = storyboard.InstantiateViewController("StoryBoardViewController");
var window = UIApplication.SharedApplication.KeyWindow;
window.RootViewController = controller;
window.MakeKeyAndVisible();
}
}
}
Here's the Wikitude View Controller Class
using System;
using CoreGraphics;
using Foundation;
using UIKit;
using CoreMedia;
using Wikitude.Architect;
namespace UXDivers.Artina.Grial
{
public partial class ExampleArchitectViewDelegate : WTArchitectViewDelegate
{
public override void InvokedURL(WTArchitectView architectView, NSUrl url)
{
Console.WriteLine ("architect view invoked url: " + url);
}
public override void DidFinishLoadNavigation(WTArchitectView architectView, WTNavigation navigation)
{
Console.WriteLine ("architect view loaded navigation: " + navigation.OriginalURL);
}
public override void DidFailToLoadNavigation(WTArchitectView architectView, WTNavigation navigation, NSError error)
{
Console.WriteLine("architect view failed to load navigation. " + error.LocalizedDescription);
}
}
public partial class WikitudeSDKExampleViewController : UIViewController
{
private WTArchitectView architectView;
private WTAuthorizationRequestManager authorizationRequestManager = new WTAuthorizationRequestManager ();
private ExampleArchitectViewDelegate architectViewDelegate = new ExampleArchitectViewDelegate ();
private WTNavigation loadingArchitectWorldNavigation = null;
private bool authorized = false;
public WikitudeSDKExampleViewController (IntPtr handle) : base (handle)
{
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
#region View lifecycle
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
this.architectView = new Wikitude.Architect.WTArchitectView ();
this.architectView.Delegate = architectViewDelegate;
this.architectView.ShouldAuthorizeRestrictedAPIs = false;
this.View.AddSubview (this.architectView);
this.architectView.TranslatesAutoresizingMaskIntoConstraints = false;
NSDictionary views = new NSDictionary (new NSString ("architectView"), architectView);
this.View.AddConstraints (NSLayoutConstraint.FromVisualFormat("|[architectView]|", 0, null, views));
this.View.AddConstraints (NSLayoutConstraint.FromVisualFormat("V:|[architectView]|", 0, null, views));
architectView.SetLicenseKey ("qb0APVM+s+0ab+QN8CIGXAjxmetYYiCSQ6wK3mnWl31YV2BKuDT8EncCMuZcCev2rgnvaVzhU3hcfoXUv3rwCTZ7HEgNUD0Fp+qntzv7Usjf2fBuQz1HZ9IEhr7o9O5YbKdwsTdIf1wEywQKAGYmLgDwfoaaE8Bciyh7L1Xm1i1TYWx0ZWRfX4squ7p4M/QBfCETAiRlme5mizo+X1Z5K1y4xpS6JNRp+JE5aIbw4rcgF2Onp4wmQypiD9lXMpM7vv0sCDU3NGOorbw1ni/kahQpXWFxRpSnVRYu772ATIZ/JWMY7O60m0JWkA1YgSczMV4SioFGA1R2tReC1l9rQw+hN395FoV40zceQykZTlb/KPW3n3+3FlgfHXgq+A0KrCv+TfbZhAnQg6z39ED0unJXnCdIdjHve1WhUClaovbcqOGrdllxVgi/85V+RG9TerH/owLju07FS5QwPL+LuHkbQ0blPqoK7uvQv+cUSXc6Chxjn3Ht49TIiFt9ishzhxfuAvTsSg84kyO0Es+aQNwZV/anS6h1i7R9UDn8I2XXZKu5IHSGaEk7gQstVgyLdvMDOyHt4LJk/q28UCEXxIOYLTcewhQyevfgmeyV2a3VnXWEMpbIqGITf343UsxZq62WD4y/iTwbwAFTun9X058QqSS0Tn6TcXH5Ef4RmJo=");
NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidBecomeActiveNotification, (notification) => {
StartAR();
});
NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillResignActiveNotification, (notification) => {
StopAR();
});
}
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
}
public override void ViewDidAppear (bool animated)
{
base.ViewDidAppear (animated);
if (!authorizationRequestManager.RequestingRestrictedAppleiOSSDKAPIAuthorization)
{
NSOrderedSet<NSNumber> restrictedAppleiOSSKDAPIs = WTAuthorizationRequestManager.RestrictedAppleiOSSDKAPIAuthorizationsForRequiredFeatures(WTFeatures.WTFeature_ImageTracking);
authorizationRequestManager.RequestRestrictedAppleiOSSDKAPIAuthorization(restrictedAppleiOSSKDAPIs, (bool success, NSError error) => {
authorized = success;
if (success)
{
StartAR();
}
else
{
handleAuthorizationError(error);
}
});
}
}
public override void ViewWillDisappear (bool animated)
{
base.ViewWillDisappear (animated);
}
public override void ViewDidDisappear (bool animated)
{
base.ViewDidDisappear (animated);
StopAR ();
}
#endregion
#region Rotation
public override void WillRotate(UIInterfaceOrientation toInterfaceOrientation, double duration)
{
base.WillRotate (toInterfaceOrientation, duration);
architectView.SetShouldRotateToInterfaceOrientation (true, toInterfaceOrientation);
}
public override bool ShouldAutorotate()
{
return true;
}
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations ()
{
return UIInterfaceOrientationMask.All;
}
#endregion
#region Segue
[Action("UnwindToMainViewController")]
public void UnwindToMainViewController()
{
}
#endregion
#region Private Methods
private void handleAuthorizationError(NSError authorizationError)
{
NSDictionary unauthorizedAPIInfo = (NSDictionary)authorizationError.UserInfo.ObjectForKey(WTAuthorizationRequestManager.WTUnauthorizedAppleiOSSDKAPIsKey);
NSMutableString detailedAuthorizationErrorLogMessage = (NSMutableString)new NSString("The following authorization states do not meet the requirements:").MutableCopy();
NSMutableString missingAuthorizations = (NSMutableString)new NSString("In order to use the Wikitude SDK, please grant access to the following:").MutableCopy();
foreach (NSString unauthorizedAPIKey in unauthorizedAPIInfo.Keys)
{
NSNumber unauthorizedAPIValue = (NSNumber)unauthorizedAPIInfo.ObjectForKey(unauthorizedAPIKey);
detailedAuthorizationErrorLogMessage.Append(new NSString("\n"));
detailedAuthorizationErrorLogMessage.Append(unauthorizedAPIKey);
detailedAuthorizationErrorLogMessage.Append(new NSString(" = "));
detailedAuthorizationErrorLogMessage.Append(WTAuthorizationRequestManager.StringFromAuthorizationStatusForUnauthorizedAppleiOSSDKAPI(unauthorizedAPIValue.Int32Value, unauthorizedAPIKey));
missingAuthorizations.Append(new NSString("\n *"));
missingAuthorizations.Append(WTAuthorizationRequestManager.HumanReadableDescriptionForUnauthorizedAppleiOSSDKAPI(unauthorizedAPIKey));
}
Console.WriteLine(detailedAuthorizationErrorLogMessage);
UIAlertController settingsAlertController = UIAlertController.Create("Required API authorizations missing", missingAuthorizations, UIAlertControllerStyle.Alert);
settingsAlertController.AddAction(UIAlertAction.Create("Open Settings", UIAlertActionStyle.Default, (UIAlertAction obj) =>
{
UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));
}));
settingsAlertController.AddAction(UIAlertAction.Create("NO", UIAlertActionStyle.Destructive, (UIAlertAction obj) => { }));
this.PresentViewController(settingsAlertController, true, null);
}
private void StartAR()
{
if (authorized)
{
if (!architectView.IsRunning)
{
architectView.Start((startupConfiguration) =>
{
// use startupConfiguration.CaptureDevicePosition = AVFoundation.AVCaptureDevicePosition.Front; to start the Wikitude SDK with an active front cam
startupConfiguration.CaptureDevicePosition = AVFoundation.AVCaptureDevicePosition.Back;
startupConfiguration.CaptureDeviceResolution = WTCaptureDeviceResolution.WTCaptureDeviceResolution_AUTO;
startupConfiguration.TargetFrameRate = CMTime.PositiveInfinity; // resolves to WTMakeTargetFrameRateAuto();
}, (bool isRunning, NSError startupError) => {
if (isRunning)
{
if (null == loadingArchitectWorldNavigation)
{
var path = NSBundle.MainBundle.BundleUrl.AbsoluteString + "x_Demo_2_SolarSystem(Geo)/index.html";
loadingArchitectWorldNavigation = architectView.LoadArchitectWorldFromURL(NSUrl.FromString(path), Wikitude.Architect.WTFeatures.WTFeature_ImageTracking);
}
}
else
{
Console.WriteLine("Unable to start Wikitude SDK. Error (start ar): " + startupError.LocalizedDescription);
}
});
}
architectView.SetShouldRotateToInterfaceOrientation(true, UIApplication.SharedApplication.StatusBarOrientation);
}
}
private void StopAR()
{
if (architectView.IsRunning)
{
architectView.Stop();
}
}
#endregion
}
}
Here's the iphone storyboard
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4451" systemVersion="13A461" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="15">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733.0"/>
</dependencies>
<scenes>
<!--class Prefix:identifier View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="WikitudeSDKExampleViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="3"/>
<viewControllerLayoutGuide type="bottom" id="4"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="64" width="768" height="960"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<navigationItem title="Wikitude SDK" id="585" key="navigationItem">
<barButtonItem key="rightBarButtonItem" title="Info" id="588">
<connections>
<segue id="780" destination="599" kind="modal" modalPresentationStyle="formSheet"/>
</connections>
<color key="tintColor" colorSpace="calibratedRGB" red="1" green="0.49803921568627452" blue="0" alpha="1"/>
</barButtonItem>
</navigationItem>
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-333" y="-299"/>
</scene>
<scene sceneID="14">
<objects>
<navigationController id="15" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="17">
<rect key="frame" x="0.0" y="20" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue id="586" destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="18" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1230" y="-294"/>
</scene>
<scene sceneID="589">
<objects>
<tableViewController id="590" sceneMemberID="viewController" customClass="WTSDKInformationViewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="592">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="590" id="593"/>
<outlet property="delegate" destination="590" id="594"/>
</connections>
<sections>
<tableViewSection headerTitle="SDK Information" id="605">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="606" rowHeight="44" style="IBUITableViewCellStyleValue1" textLabel="1061" detailTextLabel="1062">
<rect key="frame" x="0.0" y="55.5" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="606" id="607">
<rect key="frame" x="0.0" y="0.0" width="768" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Version Number:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1061">
<rect key="frame" x="48" y="12" width="128" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1062">
<rect key="frame" x="661" y="12" width="59" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="Build Information" id="612">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="613" rowHeight="44" style="IBUITableViewCellStyleValue1" textLabel="1063" detailTextLabel="1064">
<rect key="frame" x="0.0" y="293" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="613" id="614">
<rect key="frame" x="0.0" y="0.0" width="768" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Build Date:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1063">
<rect key="frame" x="48" y="12" width="83.5" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1064">
<rect key="frame" x="661" y="12" width="59" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="615" rowHeight="44" style="IBUITableViewCellStyleValue1" textLabel="1065" detailTextLabel="1066">
<rect key="frame" x="0.0" y="337" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="615" id="616">
<rect key="frame" x="0.0" y="0.0" width="768" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Build Number:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1065">
<rect key="frame" x="48" y="12" width="109" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1066">
<rect key="frame" x="661" y="12" width="59" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="617" rowHeight="44" style="IBUITableViewCellStyleValue1" textLabel="1067" detailTextLabel="1068">
<rect key="frame" x="0.0" y="381" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="617" id="618">
<rect key="frame" x="0.0" y="0.0" width="768" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Build Configuration:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1067">
<rect key="frame" x="48" y="12" width="151" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1068">
<rect key="frame" x="661" y="12" width="59" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<color key="separatorColor" colorSpace="calibratedRGB" red="1" green="0.49803921568627452" blue="0" alpha="1"/>
</tableView>
<navigationItem key="navigationItem" title="Wikitude Xamarin Component" id="591">
<barButtonItem key="rightBarButtonItem" id="619" style="done" systemItem="done">
<color key="tintColor" colorSpace="calibratedRGB" red="1" green="0.49803921568627452" blue="0" alpha="1"/>
<connections>
<segue id="1059" destination="603" kind="unwind" unwindAction="UnwindToMainViewController"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="597" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="603" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="665" y="-1542"/>
</scene>
<scene sceneID="598">
<objects>
<navigationController id="599" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="601">
<rect key="frame" x="0.0" y="20" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="590" kind="relationship" relationship="rootViewController" id="600"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="602" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-317" y="-1541"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackOpaque"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
<resources>
<image name="Default-568h.png" width="320" height="568"/>
<image name="1_ImageRecognition_1_ImageOnTarget/assets/imageOne.png" width="446" height="1024"/>
<image name="1_ImageRecognition_1_ImageOnTarget/assets/surfer.png" width="38" height="50"/>
</resources>
</document>
I deleted everything and recreated it and it worked with following code:
'public void LaunchWikitude()
{
var storyboard = UIStoryboard.FromName("MainStoryboard_iPhone", null);
var controller = storyboard.InstantiateViewController("StoryBoardViewController") as UIViewController;
var window = UIApplication.SharedApplication.KeyWindow;
window.RootViewController = controller;
window.MakeKeyAndVisible();
}'
So, I'm having issues in a project where certain strings are not being rendered properly in some old iPhones with certain iOS versions (specifically it does not work for iPhone 5 with iOS10, while it does for iOS9.3, oddly enough). To reduce the issue, I wrote this code:
import UIKit
class ViewController: UIViewController {
#IBOutlet weak var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Long HTML, although we'll make it even larger to prove a point
let string = "<h1>Thing 1</h1><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p><h1>Thing 2</h1><p>Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. </p><h1>Thing 3</h1><p>Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. </p><h1>Thing 4</h1><p>Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. Nulla facilisi. </p><h1>Thing 5</h1><p>Integer lacinia sollicitudin massa. Cras metus. Sed aliquet risus a tortor. Integer id quam. Morbi mi. Quisque nisl felis, venenatis tristique, dignissim in, ultrices sit amet, augue. Proin sodales libero eget ante. Nulla quam. Aenean laoreet. Vestibulum nisi lectus, commodo ac, facilisis ac, ultricies eu, pede. Ut orci risus, accumsan porttitor, cursus quis, aliquet eget, justo. Sed pretium blandit orci. </p><h1>Thing 6</h1><p>Ut eu diam at pede suscipit sodales. Aenean lectus elit, fermentum non, convallis id, sagittis at, neque. Nullam mauris orci, aliquet et, iaculis et, viverra vitae, ligula. Nulla ut felis in purus aliquam imperdiet. Maecenas aliquet mollis lectus. Vivamus consectetuer risus et tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. </p>"
let attrStr = try! NSAttributedString(
data: (string + string + string + string + string + string + string + string).data(using: String.Encoding.unicode,allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil)
label.attributedText = attrStr
label.backgroundColor = UIColor(red:0.00, green:1.00, blue:0.00, alpha:1.0)
}
}
Simple enough. Of course the real issue is more complicated than this, but the idea is the same.
So, in an iPhone 7, all works fine:
However, when loading it on an iPhone 4s:
When debugging, attrStr seems to be properly set in both cases.
Any ideas? My theory is that older phones are too slow to render this on time, but I'm not quite sure how to workaround this.
Thanks!
EDIT: For those that asked, this is the Storyboard:
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="JzW-qG-LFG">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="9PR-d2-hNU">
<objects>
<viewController id="JzW-qG-LFG" customClass="ViewController" customModule="things" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="VGp-YT-QQN"/>
<viewControllerLayoutGuide type="bottom" id="SeT-t7-CD0"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="gtg-CO-E9d">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Id1-A1-RaT">
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="Id1-A1-RaT" secondAttribute="trailing" id="0qp-Rk-PC2"/>
<constraint firstItem="Id1-A1-RaT" firstAttribute="leading" secondItem="gtg-CO-E9d" secondAttribute="leadingMargin" id="3Vc-he-HqH"/>
<constraint firstItem="Id1-A1-RaT" firstAttribute="top" secondItem="VGp-YT-QQN" secondAttribute="bottom" id="7IE-fY-4H0"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="Opz-px-hsl"/>
<connections>
<outlet property="label" destination="Id1-A1-RaT" id="TNv-G9-ASE"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="qlV-6d-ISJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2848.8000000000002" y="-280.20989505247377"/>
</scene>
</scenes>
</document>
The problem here is that UIView has an undocumented height limit of 8192 points. Once the label is 8192 points tall (or taller), it no longer updates the frame buffer. (Presumably the window server simply ignores the label's CALayer once the layer is too large.) Whatever was already in the frame buffer remains there. Presumably the behavior is undefined and may vary across devices and versions of iOS.
(Edit: Having thought about this more, I suspect the limit is 16,384 pixels, not 8,192 points. I don't think the window server deals in points.)
To demonstrate, I took your code and storyboard and added three things:
I constrained the height of your label to be less than or equal to 8185 points.
I added a slider that updates the constant of that height constraint. The slider allows the range 8185 to 8200.
I added another label that displays the constant of the height constraint.
Here's what happens in the iPhone SE simulator running iOS 10.2:
In the demo, you can see that as soon as the height limit crosses 8192 points, the thumb of the slider starts to look smeared, and the height label's text visibly overwrites itself. This is because the green label is no longer updating the frame buffer, so whatever was previously there (as drawn by the slider and the height label) remains, only overwritten where the slider and the height label redraw themselves. As soon as the height goes back down across the 8192 point threshold, the green label draws itself again, cleaning up the mess.
I think you're not seeing this in your iPhone 7 test because the iPhone 7 has a wider screen than the iPhone SE. All iPhones with 3.5 inch and 4 inch screens are 320 points wide. iPhones with 4.7 inch screens are 375 points wide, and iPhones with 5.5 inch screens are 414 points wide.
A wider screen means a wider UILabel. That means more text fits on each line, so the label doesn't have to be as tall to fit all the text. I suspect that on the larger screens, your labels are shorter than 8192 points so they don't hit undefined behavior.
Workarounds:
If you don't intend to let the user scroll to see the entire text, just put a height constraint on the label.
If you want to let the user scroll, try using a UIWebView or WKWebView instead of a UILabel to show the text. I believe these views can handle content more than 8192 points tall.
Incidentally, you're not the first person to run into this problem: UILabel view disappear when the height greater than 8192. However, your question currently has an open bounty, which prevents it from being closed as a duplicate.
You haven't provided any details about your Storyboard, or the settings or constraints for your label.
So I have initiated the label programmatically, and this solution works on the iPhone 4s running iOS 9.3:
Here is the working source code:
override func viewDidLoad() {
super.viewDidLoad()
label = UILabel(frame: CGRect(x: 0.0, y: 44.0, width: view.frame.size.width, height: view.frame.size.height - 88.0))
label.numberOfLines = 0
label.isUserInteractionEnabled = false
label.contentMode = .left
label.textAlignment = .natural
label.lineBreakMode = .byTruncatingTail
label.baselineAdjustment = .alignBaselines
label.adjustsFontSizeToFitWidth = false
// label.translatesAutoresizingMaskIntoConstraints = false //setting this causes the text to be layout wrong
label.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]
view.addSubview(label)
// Long HTML, although we'll make it even larger to prove a point
let string = "<h1>Thing 1</h1><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p><h1>Thing 2</h1><p>Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. </p><h1>Thing 3</h1><p>Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. </p><h1>Thing 4</h1><p>Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. Nulla facilisi. </p><h1>Thing 5</h1><p>Integer lacinia sollicitudin massa. Cras metus. Sed aliquet risus a tortor. Integer id quam. Morbi mi. Quisque nisl felis, venenatis tristique, dignissim in, ultrices sit amet, augue. Proin sodales libero eget ante. Nulla quam. Aenean laoreet. Vestibulum nisi lectus, commodo ac, facilisis ac, ultricies eu, pede. Ut orci risus, accumsan porttitor, cursus quis, aliquet eget, justo. Sed pretium blandit orci. </p><h1>Thing 6</h1><p>Ut eu diam at pede suscipit sodales. Aenean lectus elit, fermentum non, convallis id, sagittis at, neque. Nullam mauris orci, aliquet et, iaculis et, viverra vitae, ligula. Nulla ut felis in purus aliquam imperdiet. Maecenas aliquet mollis lectus. Vivamus consectetuer risus et tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. </p>"
let attrStr = try! NSAttributedString(
data: (string + string + string + string + string + string + string + string).data(using: String.Encoding.unicode,allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil)
label.attributedText = attrStr
label.backgroundColor = UIColor(red:0.00, green:1.00, blue:0.00, alpha:1.0)
}
A complete working project may be downloaded from here.
You are most definitely right. This is a time issue.
NSHTMLTextDocumentType of NSDocumentTypeDocumentAttribute is notorious for taking very long times. As you increase the attrStr string length (adding a couple of + string in data ) you'll be able to replicate the bug for higher end devises after a certain string length. I can reproduce this in an iPhone 6 plus emulator using iOS 10.1, since emulator works with less processing power than the actual devise.
If it's viable to you, you may try using DTCoreText to solve this issue. This library handles html string with methods other than the built in ones, reducing the rendering times. Which will make the bug less noticeable in lower end mobiles.
I found a weird issue with my fixed header under the following conditions:
iphone 6+, landscape mode
safari, at least two tabs opened
my page has a position: fixed header and a body and html with position: relative, height: 100%
After page loads and when scrolling down, all works good, the header is in place and web inspector shows it correctly:
But when you scroll up and pull the page down the screen and release, the header is still visible on the page, but actually it is shifted somewhere below the viewport (see that web inspector does not highlight it).
This fact results in all header elements being unaccessible: you cannot open the menu, click on the logo, or contact button.
The header goes back to normal when:
you scroll down (but breaks again when you scroll back up)
switch to another tab and back
or close other tabs
I tried changing DOM or/and CSS of the header and body, but nothing puts the header back to normal state.
Any thoughts on how it can be fixed?
I am sorry to be the messenger of bad news, but I have no idea what your actual problem is since you posted no actual code. However, I would guess that since your problem is position:fixed, the best way to fix it is by stopping using position:fixed as it seems to not be working for you. Here is how you can equally-smoothly emulate it using only absolute and relative positioning:
<html id="eHTML">
<style>
#eHTML { position: static }
#eBODY { position: relative; overflow:hidden }
#eHTML, #eBODY, #main { width: 100%; height: 100%; margin: 0; top: 0 }
#eBODY>div { position:absolute; left:0;bottom:0 }
#footer {height: 20%;background-color:#88f;width:calc(100% - 14px)/*to account in for 14px scrollbar*/;overflow:hidden}
#main {background-color:#ff8;width:100%;height:100%;overflow:auto}
</style>
<body id=eBODY>
<div id=main>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium,</p>
<p>totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
<p>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
<p>Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit,</p>
<p>sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.</p>
<p>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</p>
<p>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur,</p>
<p>vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
<br /><br /><br /><br />
</div>
<div id="footer">
Some Random Fixed<br />
Content! Yay, it workz!
</div>
</body>
</html>
I'm migrating old app from .xib-s to .storyboard-s. Those .xibs have many IBOutlet connections and it is very time consuming to copy&paste the view and recreate them. I was wondering if there is a way to do this seamlessly. Anybody knows solution to this problem?
Yes there is a way.
Ensure the storyboard view controller scene has the correct class set for the view controller.
Right click on the xib file, and select Open As -> Source Code.
Locate the <subviews> ... </subviews> pair of tags, and copy the section.
Open the storyboard in the same way (Open As -> Source Code) and locate the corresponding view controller in the xml (marked by an xml comment eg <!--MyViewController>), and copy and paste you subviews xml from the xib, inside the view controllers <view> ... </view> tags. Eg
<viewController id="vXZ-lx-hvc" customClass="TwoViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fLe-1C-hTu">
<rect key="frame" x="116" y="244" width="46" height="30"/>
<state key="normal" title="Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
Repeat the above steps with the <connections> ... </connections> to copy across all the IBOutlets. Note that the connections go underneath the <view> .. </view> tags, but inside the <viewController> ... </viewController>
<viewController id="vXZ-lx-hvc" customClass="TwoViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fLe-1C-hTu">
<rect key="frame" x="116" y="244" width="46" height="30"/>
<state key="normal" title="Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="samButtonTap:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="1sQ-0S-S8z"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="samButton" destination="fLe-1C-hTu" id="8GK-Nn-Loy"/>
</connections>
</viewController>
You'll notice from the second snippet that IBActions are represented with the view, where as IBOutlets are represented together after the subviews have been declared.
You may need to do more, depending on how complex you xib file is. If you decide to recreate some of your xib components rather than copy them across the ids will change, so be aware of that. Don't forget to delete you xib file from the project once you're done.