iOS Development Hundred Questions (11)

Source: Internet
Author: User
131, how to limit scrollview in a certain direction is not scrollable?
For example, to restrict non-scrolling in the x direction, 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 into the SWIFT framework target
Take BMOBSDK as an example (the same is true for c/o-c frameworks such as Commoncrypto), and when you add bmobsdk to link Binary with libraries, an error occurs when you use the "IMPORTBMOBSDK" statement: No Such module
If you try to import bmobsdk using bridging headers, you will cause another error.
This is because the SWIFT framework does not support bridging headers files.
To solve this problem, you need to go through the following steps:
1) Create the BMOBSDK directory in the project directory and place the bmobsdk.framework in this directory. Also create a module.map file in this directory with the following contents:

Module BMOBSDK [System] {header/users/kmyhy/documents/swift/code/12th Chapter/knote/bmobsdk/bmobsdk.framework/headers/ Bmob.h "link" bmobsdk "Export *}"

This will allow us to use BMOBSDK as Swift module.
2) In Build settings, locate the import Paths (swift_include_paths) and add the BMOBSDK directory. As shown in:

3) Import the BMOBSDK framework into the swift file:
Import bmobsdk

133, how to use Cocoapods
in app extension to add this sentence in Podfile:
Link_with ' extended Name '
to add the bridging header file and set the Objective-c Bridgingheader.
134, error ' XXX.PCH ' has been modified since the precompiled header is builterror in Xcode
Perform depth clean (shortcut key Option+command +SHIFT+K)

135, Document provider extension, Documentpickerviewcontroller's Documentstorageurl property is returned as nil.
Confirm that the app groups settings for the container app,document provider extension and file provider extension are correct, and if there are any exclamation points, please fixed.
136, inserting and deleting cells in CollectionView
like TableView, we can insert with insertitemsatindexpaths ()/deleteitemsatindexpaths () Deletes a cell. The difference is that Collecionview no longer supports the beginupdates ()/endupdates () operation. Insert/Delete animations are supported by default, and you can set the Animationsenabled property of UIView If you do not want the default animation effect:

BOOL animationsenabled = [UIView areanimationsenabled]; [UIView Setanimationsenabled:no]; [Mycollectionview reloaditemsatindexpaths:myindexpaths]; [UIView setanimationsenabled:animationsenabled];

137, Uiscrollview in the Uicollectionview will not scroll
Check whether the Uiscrollview is set with the Delegate property, and check whether the Scrollviewdidscroll method is implemented in delegate. If so, delete the method (simply canceling the delegate property is not possible).
Also check the width (or width constraint), height (or height constraint) of the Uicollectionview, and the size of the list content, because scroll bars in that direction do not appear when the contents of the list are smaller than the width (or height) of Uicollectionview.
138, cell use UITableViewCellStyleValue1, why is not displayed correctly?
UITableViewCell has several built-in types, such as Uitableviewcellstyledefault, UITableViewCellStyleValue1, and UITableViewCellStyleValue2.
These cells are pre-configured in the SDK, and they present fixed built-in styles such as font size, color, alignment, and so on. If you want to modify these configurations, it is likely to show abnormal, such as some text can be displayed at a sudden, do not display at once, or suddenly display the inherent font (and color), suddenly (for example, click on the cell) and display the modified font (and color).
In this case, you'd better customize your own cell (subclass).
139, Boundingrectwithsize calculated the size is not correct?
Note the correct options parameters are provided. For Uilabel, you need to use at least the Useslinefragmentorigin and usesfontleading two options:

CGRect paragraphrect =[attributedtextboundingrectwithsize:cgsizemake (300.F, Cgfloat_max) options: ( nsstringdrawinguseslinefragmentorigin| nsstringdrawingusesfontleading) Context:nil];

140. Cannot perform bitwise OR (|) operations on multiple enumeration values in Swift
Note that this issue was addressed in IOS 8.3 SDK Beta 1 (12f5027d). For the SDK below this version, we can replace it with the following code:

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 iOS Development Hundred questions (11) content, more relevant content please pay attention to topic.alibabacloud.com (www.php.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.