IOS development FAQ (11)

Source: Internet
Author: User
How do I restrict ScrollView from scrolling in a certain direction? For example, to restrict x to non-scroll, you can implement the UIScrollViewDelegate protocol method: 131. how to restrict ScrollView to non-scroll in a certain direction?
For example, to restrict the x direction from scrolling, you can implement the UIScrollViewDelegate protocol method:

func scrollViewDidScroll(scrollView: UIScrollView) {ifabs(scrollView.contentOffset.x) > 0 {scrollView.contentOffset= CGPointMake(0, scrollView.contentOffset.y)}}

132. how to import the O-C Framework to the Swift Framework target
Take BmobSDK as an example (CommonCrypto and other C/O-C frameworks are the same), when you add BmobSDK to Link Binary With Libraries, when you use the "importBmobSDK" statement, an error occurs: no such module
If you try to use bridging headers to import BmobSDK, another error may occur.
This is because Swift Framework does not support the bridging headers file.
To solve this problem, follow these steps:
1) create the BmobSDK directory in the project directory and put BmobSDK. framework in this directory. Create a module. map file in the directory as follows:

Module BmobSDK [system] {header "/Users/kmyhy/Documents/Swift/code/Chapter 12th/kNote/BmobSDK. framework/Headers/Bmob. h "link" BmobSDK "export *}

This will allow us to use BmobSDK as a Swift module.
2) in Build Settings, find Import Paths (SWIFT_INCLUDE_PATHS) and add the BmobSDK directory. As shown in:

3) import the BmobSDK framework to the swift file:
Import BmobSDK

133. how to use CocoaPods in App Extension
Add this sentence to Podfile:
Link_with 'extended name'
Add the bridging header file and set the Objective-C BridgingHeader.
134 error 'XXX. pch' has been modified since the precompiled header was builterror in Xcode
Execute deep Clean (shortcut: Option + Command + Shift + K)

135. in the Document Provider extension, the documentStorageURL attribute of DocumentPickerViewController is returned as nil.
Make sure that the App Groups settings of the container App, Document Provider extension, and File Provider extension are correct. if there is any exclamation point, please Fixed.
136 insert and delete cells in CollectionView
Like TableView, we can use insertItemsAtIndexPaths ()/deleteItemsAtIndexPaths () to insert/delete cells. The difference is that CollecionView no longer supports the beginUpdates ()/endUpdates () operation. By default, you can insert or delete animations. if you do not want the default animation effect, you can set the animationsEnabled attribute of UIView:

BOOL animationsEnabled = [UIView areAnimationsEnabled];[UIView setAnimationsEnabled:NO];[myCollectionView reloadItemsAtIndexPaths:myIndexPaths];[UIView setAnimationsEnabled:animationsEnabled];

137. UICollectionView in UIScrollView does not scroll
Check whether the delegate attribute is set for UIScrollView and whether the scrollViewDidScroll method is implemented in delegate. If yes, delete this method (it is not feasible to cancel the delegate attribute only ).
Check the width (or width constraints), height (or height constraints), and content size of the UICollectionView, because when the content of the list is smaller than the width (or height) of the UICollectionView, the scroll bar in this direction does not appear.
138. Why does cell UITableViewCellStyleValue1 display incorrectly?
UITableViewCell has several built-in types, such as UITableViewCellStyleDefault, UITableViewCellStyleValue1, and UITableViewCellStyleValue2.
These cells are pre-configured by the SDK and they display fixed built-in styles, such as the font size, color, and alignment. If you want to modify these configurations, it is very likely that the display is abnormal. for example, some texts can be displayed at once, but not at once, or the inherent font (and color) can be displayed at once ), the modified font (and color) is displayed at once (for example, when a cell is clicked ).
In this case, you 'd better customize your cell (subclass ).
139. is the size calculated by boundingRectWithSize incorrect?
Make sure that the correct options parameter is provided. For UILabel, at least UsesLineFragmentOrigin and UsesFontLeading must be used:

CGRect paragraphRect =[attributedTextboundingRectWithSize:CGSizeMake(300.f, CGFLOAT_MAX)options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)context:nil];

140 Swift cannot perform bitwise OR (|) Operations on multiple enumerated values
Note that this problem has been solved in iOS 8.3 SDK Beta 1 (12F5027d. For SDKs earlier than this version, we can use the following code instead:

let options =unsafeBitCast(NSStringDrawingOptions.UsesLineFragmentOrigin.rawValue |NSStringDrawingOptions.UsesFontLeading.rawValue,NSStringDrawingOptions.self)let frame = text.boundingRectWithSize(size, options:options, attributes:D,context:nil)

The above is the content of iOS development FAQ (11). For more information, see PHP Chinese website (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.